0

Why is there a class word near T in template definition?

it's kind of confusing that class is also used to declare classes...

16th Oct 2016, 1:44 AM
Busol Oleksandr
Busol Oleksandr - avatar
1 Odpowiedź
0
Maybe that's why they have introduced the keyword "typename". e.g.: template <typename T> void foo() { //... } To answer "why" in your question, Stroustrup has originally decided to use the same keyword in order to minimize number of reserved keywords. However the C++ committee has finally decided to add this new keyword to avoid possible confusions. P.S: The same keyword is used to declare that a dependent name is a type. Read more on that here: http://en.cppreference.com/w/cpp/language/dependent_name
16th Oct 2016, 5:46 AM
Sumudu
Sumudu - avatar