Possible Duplicate:
Use 'class' or 'typename' for template parameters?
I see two different template class declarations:
template <class T> class SampleClass1
{
// ...
};
and
template <typename T> class SampleClass2
{
// ...
};
What is the difference between these two codes?
EDIT: I corrected the wrong keyword "typedef" to "typename".
If by
template <typedef T> class SampleClass2
you mean
template <typename T> class SampleClass2
then there is no difference. The use of class
and typename
(in the context of a template parameter that refers to a type) is interchangeable.
The reason that both keywords are allowed here is historical. See this article for a detailed explanation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With