Export (0) Print
Expand All
Expand Minimize

Compiler Error C2027

Error Message

use of undefined type 'type'

A type cannot be used until it is defined. To resolve the error, be sure the type is fully defined before referencing it.

Example

The following sample generates C2027.

// C2027.cpp
class C;
class D {
public:
   void func() {
   }
};

int main() {
   C *pC;
   pC->func();   // C2027

   D *pD;
   pD->func();
}

It is possible to declare a pointer to a declared but undefined type. But Visual C++ does not allow a reference to an undefined type.

The following sample generates C2027.

// C2027_b.cpp
class A;
A& CreateA();

class B;
B* CreateB();

int main() {
   CreateA();   // C2027
   CreateB();   // OK
}

Community Additions

ADD
Show:
© 2014 Microsoft