What does the ‘class’ part of a template statement do?
Example:
template <class T> class Something { public: Something(const T &something); }
And what else can go there? I usually only see ‘class’.
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.
The
classkeyword means the same thing as thetypenamekeyword for the most part. They both indicates that T is a type.The only difference between the keywords
classandtypenameis thatclasscan be used to provide class template template arguments to a template, whereastypenamecan’t. Consider:The only other thing you can put in place of the
classortypenamekeywords is an integral type. For example:For a concrete example of this, take a look at
std::bitset<N>in the standard library.