Edit

Share via


Compiler Error C2989

'class' : class type has already been declared as a non-class type

The class generic or template redefines a non-template or non-generic class. Check header files for conflicts.

The following sample generates C2989:

// C2989.cpp
// compile with: /c
class C{};

template <class T>
class C{};  // C2989
class C2{};

C2989 can also occur when using generics:

// C2989b.cpp
// compile with: /clr /c
ref class GC1;

generic <typename T> ref class GC1;   // C2989
template <typename T> ref class GC2;

generic <typename T> ref class GC2;   // C2989
generic <typename T> ref class GCb;
template <typename T> ref class GC2;
generic <typename T> ref class GCc;