December 2004
Intermediate to advanced
400 pages
8h 29m
English
typename and template KeywordsThe template keyword is used to introduce template declarations and definitions:
template <class T> class vector;
The typename keyword is often used in place of class to declare template type parameters:1
template <typename T> class vector;
Both keywords also have a second role in the language. This appendix is about that role, why it is needed, and exactly how to apply typename and template to fill it. Because the rules are subtle, many people wait until the compiler complains before thinking about the use of typename or template, but it’s worth learning these technical details because:
• You’ll spend less time fixing trivial syntax errors.
• You’ll understand what you did wrong when ...
Read now
Unlock full access