Compiler Error C2460

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Compiler Error C2460.

identifier1' : uses 'identifier2', which is being defined

A class or structure (identifier2) is declared as a member of itself (identifier1). Recursive definitions of classes and structures are not allowed.

The following sample generates C2460:

// C2460.cpp  
class C {  
   C aC;    // C2460  
};  

Instead, use a pointer reference in the class.

// C2460.cpp  
class C {  
   C * aC;    // OK  
};  

Show: