Hi.
Need to know what's the difference when using Templates between: template<class T>
and template<typedef T>
Hi.
Need to know what's the difference when using Templates between: template<class T>
and template<typedef T>
Jump to PostThe first is legal, the second is not. But if you meant typename rather than typedef, the two are functionally identical.
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 !
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.