Pretty straight-forward:
template <class T>
void foo() {} //compiles
template <struct T>
void goo() {} //doesn't
Why?
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.
classis only a keyword to indicate thatTis a type. It does not actually meanTmust be a class. (e.g. you can callfoo<int>().)The
classkeyword was used becausetypenamedidn’t exist when the template feature was added. See Templates in c++,typename and class.