10 Years
Discussion Span
Last Post by VersEtreOuNe

The first is legal, the second is not. But if you meant typename rather than typedef, the two are functionally identical.


My bad i meant. template<typename T> You said they are functionally identical. Is one of them from C and the other from C++, is one of them or both of them Standard?


C doesn't have templates at all, so both class and typename are unique to C++. They're also both standard, but class is an older form[1], so you're likely to see it more often. There are various personal preferences for how to use it; my preference is to use typename pretty much exclusively.

[1] class was used originally because the designers didn't want to add a new keyword to the language. But when a new keyword was needed for other things (typename), it was basically overloaded to handle this job as well.


Ok. Thanks that's exactly what i needed to know. You are simply da best Narue !

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.