Is there a difference between a class template and template class. If so what is it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When both terms are used there is a very subtle difference. It is more linguistic than semantic, it depends on which word you are modifying.
In short, a class template is a particular kind of template. Templates can define either classes or functions. A class template is a template that defines a class. See the difference:
A template class is a particular kind of class. There are many kinds of classes, and in particular, template classes are those defined using a class template. Contrast:
From Stroustrup’s C++ Glossary:
Both expressions are used in Stroustrup’s book The C++ Programming Language, and the ISO/IEC C++ standard until 1998.
Note: As discussed in the comments below, it seems that C++03 doesn’t use the term “template class” anymore (although I don’t have a copy of it), presumably to reduce confusion. As I said before, they are fundamentally the same thing, it is just a linguistic difference: in the templates context you refer to a particular kind of template or in the classes context you refer to a particular kind of class. If you just stick to “class template”, you won’t lose anything.
More food for thought: