Compiler Error C2899
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Error C2899

typename cannot be used outside a template declaration

The typename keyword can be used only in a template definition or declaration. In a template declaration, it can be used in two ways:

// C2899.cpp
// compile with: /c
template<typename T> 
class X {};

// Another way
template<class T> 
struct XX {
   typename T::A a;   // T::A is a type

The following sample generates C2899:

// C2899b.cpp
// compile with: /c
struct Y {
   typedef int B;
   typename Y::B b;   // C2899
© 2015 Microsoft