devxlogo

Template Parameters and Template Arguments

Template Parameters and Template Arguments

The terms template argument and template parameter do not mean the same thing. A template parameter is a symbol, or a placeholder which is replaced by the actual argument when you instantiate a template. For example, T in the following template is a template parameter:

 template  class List{ //..};

size=3>
A template argument is a typename or a const value that a template instance uses. For example:

 List  li; // 'int' is a template argument

size=3>
The parameter T is substituted for the arguments ‘int’ when the List specialization is instantiated.

devx-admin

Share the Post: