Compiler Error C2955


For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

'identifier' : use of class template or alias generic requires template or generic argument list

You cannot use a class template or class generic as an identifier without a template or generic argument list.

For more information, see Class Templates.

The following sample generates C2955 and shows how to fix it:

// C2955.cpp  
// compile with: /c  
template<class T>   
class X {};  
X x1;   // C2955  
X<int> x2;   // OK - this is how to fix it.  

C2955 can also occur when attempting an out-of-line definition for a function declared in a class template:

// C2955_b.cpp  
// compile with: /c  
template <class T>  
class CT {  
   void CTFunc();  
   void CTFunc2();  
void CT::CTFunc() {}   // C2955  
// OK - this is how to fix it  
template <class T>  
void CT<T>::CTFunc2() {}  

C2955 can also occur when using generics:

// C2955_c.cpp  
// compile with: /clr  
generic <class T>   
ref struct GC {   
   T t;  
int main() {  
   GC^ g;   // C2955  
   GC <int>^ g;