Saturday, January 18, 2014

template class or class template

class template vs template class : templates tutorial ccplusplus.com

"Class Template" or "Template Class"?

In C++, structs, classes, and unions are collectively called class types. Without additional qualification, the word "class" in plain text type is meant to include class types introduced with either the keyword class or the keyword struct. Note specifically that "class type" includes unions, but "class" does not. (In C++, the only difference between class and struct is that the default access for class is private whereas the default access for struct is public. However, we prefer to use class for types that use new C++ features, and we use struct for ordinary C data structure that can be used as "plain old data" (POD).)

There is some confusion about how a class that is a template is called:
  • The term class template states that the class is a template. That is, it is a parameterized description of a family of classes.
  • The term template class on the other hand has been used
    - as a synonym for class template.
    - to refer to classes generated from templates.
    - to refer to classes with a name that is a template-id.
The difference between the second and third meaning is somewhat subtle and unimportant for the remainder of the text.

Because of this imprecision, we avoid the term template class in our tutorials. Similarly, we use function template and member function template, but avoid template function and template member function.








-----------------------------------------------------------------
See Also:
-----------------------------------------------------------------

-----------------------------------------------------------------

No comments:

Post a Comment