Export (0) Print
Expand All

typename

The typename keyword tells the compiler that an unknown identifier is a type.

typename identifier;

Use this keyword only in template definitions. For example:

// typename.cpp
template<class T> class X
{
   typename T::Y m_y;   // treat Y as a type
};

int main()
{
}

This keyword can also be used in place of class in template parameter lists. For example, the following statements are identical:

template<class T1, class T2>...
template<typename T1, typename T2>...

See Also

Templates | C++ Keywords

Show:
© 2014 Microsoft