First of all, note that in the definition of MyClass in two ways, two declare the class as
template< class T > class MyClass
and
template< typename T > class MyClass
equivalent, you do not give the compiler more information using one keyword compared to another.
In addition, I would say that the compiler is right, MyClass <int> will not work, because you cannot write int :: something in C ++, whereas, for example, MyClass <std :: string> will work fine.
source share