function template
template
template
class template
should be defined inline within the class declaration, otherwise should be preceded the definition with the template <…> prefix
Template specialization
the different implementation for a template when a specific type is passed as template parameter, we can define template specialization
generic class template and the specialization:
template
template <> class mycontainer
default parameter for template
template
disadvantage of template
Because templates are compiled when required, this forces a restriction for multi-file projects: the implementation (definition) of a template class or function must be in the same file as its declaration. That means that we cannot separate the interface in a separate header file, and that we must include both interface and implementation in any file that uses the templates.
Resource :
http://www.cplusplus.com/doc/tutorial/templates.html
No comments:
Post a Comment