------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-12-31 13:23 ------- The 'typename' keyword is required because later C++ introduces a lot more features. Those that interfere with your code are partial specialization and specialization. For example, you can now have specialization
template <> class tstack<bool> { int link; ... }; Then when you declare tstack<bool> t; it will use the above declaration, where 'link' is now a member data instead of a nested class. So the code tstack<T>::link* p; which could be interpreted as declaring a variable which is a pointer to type 'tstack<T>::link' if 'T' is 'int'. But when 'T' is 'bool' it could means multiplying a member data with another variable named 'p'. To resolve the ambiguity, later C++ requires the 'typename' keyword to treat as pointer declaration, otherwise it will be treated as muliplication. Older C++ books don't have this 'typename' keyword but newer good books from respected authors coming out in the last few years should. (Many new C++ books are still wrong). I know the parser error message could be improved, and there are plenty of bug reports elsewhere about it. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19188