I am reading the book Thinking in C++ (2nd edition Vol 1) and i have a problem when i try to compile this source code:
http://www.linuxtopia.org/online_books/programming_books/thinking_in_c++/Chapter16_015.html
The problem appears to be in that line:
Stack::Link* p;
As i have read in C++: error "… is not derived from type …"
i have to add the word “typename” (or “class”) in front of it.
Is the book wrong in this example or am I missing something?
Yes, it’s wrong. You need the
typename. See the typename and template FAQ entry.Stackis a dependent type andStack::Listis a dependent type too. This is legal in C++0x, but it’s illegal in current C++.