Effective C++ Ed. 3rd: Item 42. Understand the two meanings of typename

What's the difference between the following two declarations:
template<class T> class Widget;                 // uses "class"

template<typename T> class Widget;              // uses "typename"

When declaring template parameters, class and typename are interchangeable.
But use typename to identify nested dependent type names, except in base class lists or as a base class identifier in a member initialization list.
prev | next

No comments:

Post a Comment