"class template" versus "template class" [duplicate]
Possible Duplicate:
What is the difference between a template class and a class template?
I've seen several C++ gurus rip on people for calling something like
template <typename T>
class SomeClass
{
//...
};
a template class instead of a class template. (Not a huge rip, mind you, but as an indication that someone isn't an experienced C++ programmer) Yes, the correct word is "class template" -- because it is a template used to generate classes.
But I don't understand why in typical conversation the di开发者_高级运维stinction matters. Nobody listening to/reading what you've written is going to understand what you're talking about to mean anything else.
Is there some specific use of the words "template class" in the standard or otherwise which makes use of those words in that order grossly wrong?
According to this page :
Note the distinction between the terms class template and template class:
- Class template is a template used to generate template classes. You cannot declare an object of a class template.
- Template class is an instance of a class template.
This MSDN page seems to agree on this definition :
Unlike function templates, when instantiating a class template, you must explicitly instantiate the class by giving the arguments for the class templates.
[...]
The compiler generates code for a template class or function when the class or function is instantiated.
A quick search yielded:
Q: Is there a difference between a function template and a template function, or between a class template and a template class?
A: The term "function template" refers to a kind of template. The term "template function" is sometimes used to mean the same thing, and sometimes to mean a function instantiated from a function template. This ambiguity is best avoided by using "function template" for the former and something like "function template instance" or "instance of a function template" for the latter. Note that a function template is not a function. The same distinction applies to "class template" versus "template class".
Makes sense to me.
I personally wouldn't make the correction, but I can see the logic behind it. It's no different than calling a superclass a subclass or vice-versa. What they're saying is inherently incorrect, and does not mean the same thing.
It's important, especially with more junior programmers, to think in terms of code, and that is not possible when you are translating the language back into english incorrectly.
精彩评论