Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
typename

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:
© 2015 Microsoft