C++ template typename iterator

In list<tNode<T>*>::iterator, you have a dependant name, that is, a name that depends on a template parameter. As such, the compiler can’t inspect list<tNode<T>*> (it doesn’t have its definition at this point) and so it doesn’t know whether list<tNode<T>*>::iterator is either a static field or a type. In such a situation, the compiler assumes that … Read more

Why is the keyword “typename” needed before qualified dependent names, and not before qualified independent names?

A name in C++ can pertain to three different tiers of entities: Types, values, and templates. struct Foo { typedef int A; // type static double B; // value template <typename T> struct C; // template }; The three names Foo::A, Foo::B and Foo::C are examples of all three different tiers. In the above example, … Read more