Template Syntax

The syntax for a template is:

                 /------------------------\
>>--template--\-----argument-declaration----->--><
              |   |                      |
                  \-type--identifier-----/

The declaration in a template declaration must define or declare one of the following:


The identifier of a type is defined to be a type_ name in the scope of the template declaration. A template declaration can appear as a global declaration only.

The template arguments (within the < and > delimiters) specify the types and the constants within the template that must be specified when the template is instantiated.

Default intializers are permitted in template arguments, under the following conditions:

Note: A template that defines a member function of a class template is treated as a function template. Such a template cannot have default intializers.



Structuring Your Program Using Templates
Class Templates


Examples of Templates
Example of Default Initializers in Templates


Function Templates
Static Members