Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8879215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:54:07+00:00 2026-06-14T19:54:07+00:00

I yesterday read about Expression Parameters in C++ : http://www.learncpp.com/cpp-tutorial/144-expression-parameters-and-template-specialization/ I know why you

  • 0

I yesterday read about Expression Parameters in C++ :
http://www.learncpp.com/cpp-tutorial/144-expression-parameters-and-template-specialization/

I know why you use templates, but why use Expression Parameters when you can just use the constructor to accomplish the same thing?
Oh, and one more thing, are templates handled by the precompiler?

Thank You in Advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:54:09+00:00Added an answer on June 14, 2026 at 7:54 pm

    When you use a template class it will be expanded at compile time and then compiled like a normal class. One reason to use an expression parameter instead of a parameter in a constructor is that the expression becomes part of the type. So all objects of that type will be guaranteed to use the same value.

    In the example you linked to:

    // declare an integer buffer with room for 12 chars
    Buffer<int, 12> cIntBuffer;
    

    cIntBuffer is an instance of the class Buffer. It is guaranteed to have a int buffer of size 12. If you had:

    Buffer<int> cIntBuffer1(12); 
    Buffer<int> cIntBuffer2(13);
    

    cIntBuffer1 and cIntBuffer2 are the same type of object, but they have different buffer sizes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read the following article yesterday ( http://blogs.sitepoint.com/2010/11/19/mysql-mistakes-php-developers/ ) and it wrote the following:
Initial Question Yesterday i read about ECMAScript 5 Object.create() And I wanted to start
Yesterday,I read the glassfish embed example this address is: http://weblogs.java.net/blog/arungupta/archive/2008/11/totd_56_simple.html but I running the
So i did read a lot about Azure yesterday as i'm considering my plans
Yesterday I've posted question about SQLite performance issues ( Terrible performance in Zend Db
yesterday I took a database exam and the question about normalization was strange. We
I asked the same question yesterday and the answer was not applicable. https://stackoverflow.com/questions/6194578/breaking-up-class-functions-into-multiple-cpp-files If
Yesterday I read some code of a colleague and came across this: class a_class
Yesterday I read a problem which can be translated into the following problem with
Inspired by an article which I read yesterday, I am striving to add a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.