You cannot access typedef or members of a template class directly in the base class, because at this point it is not a complete type. This can lead to cyclical behavior:
template<class Derived> struct Test { typedef typename Derived::value_type foo; }; struct Derived : public Test<Derived> { typedef Test<Derived>::foo value_type; };
However, you can refer to the members of the template class in methods, since they are not fully created:
template<class Derived> struct Test { void foo() { typename Derived::value_type bar; } }; struct Derived : public Test<Derived> { typedef int value_type; };
Alternatively, depending on what you are trying, you can pass a typedef as an additional template parameter:
template<typename value_type, class Derived> struct Test { template<class T> value_type foo(T); }; struct Derived : public Test<int, Derived> { typedef int value_type; };
source share