typename cannot be used outside a template declaration
The typename keyword can be used only in a template definition or declaration. In a template declaration, it can be used in two ways:
// One way template<typename T> class X {}; // Another way template<class T> struct X { typename T::A a; // T::A is a type };
Example
struct Y { typedef int B; typename Y::B b; //error };