typename cannot be used outside a template declaration
The typename keyword can only be used in a template definition or declaration. In a template declaration, it can be used in two ways. See the example below:
// one way to use typename
template<typename T> class X {};
// another way to use typename
template<class T> struct X {
   typename T::A a;   // T::A is a type
};
If typename is used outside a template declaration, this error will be generated. For example:
struct Y {
   typedef int B;
   typename Y::B b;   //illegal
};