The typename Keyword
Indicates that the name following represents a parameterized type placeholder that will be replaced by a user-specified actual type.
consider the following example:
template<class T> class A
{
T::x(y); // ambiguous: calling a function or constructing an object?
// without ‘typename’ this will be interpreted as a function call
typedef char C;
A::C d;
}
The statement A::C d; is ill-formed. The class A also refers to A<T> and thus depends on a template parameter. You must add the keyword typename to the beginning of this declaration:
typename A::C d;
You can also use the keyword typename in place of the keyword class in template parameter declarations.
typename was introduced after the keyword class to solve the problems shown above, but both keywords are equivalent in declaring template parameters.