In both cases, the templates are instantiated automatically by the compiler. Objects of this class can now be created using SomeCharClass as a class name. A function template is instantiated when a call to the function occurs with parameters of a specific type. In either case, it the same template is used more than once with the same types of parameter in same compilation, it is instantiated only once. In either case, a template specification begins with the reserved word template, followed by a list of formal parameters enclosed in angle brackets, followed by the definition of the template.
Templates can have any number of parameters.
The parameters can be either types or values or objects. Datatype parameters are specified by using the word class. They can be either standard types or class types - the word class in this context has a broad meaning. A template specification is normally placed in a header file, but must include the complete implementation of the template, since the compiler must construct a custom implementation each time the template is used. Associative containers Set Multiset Map Multimap 2.