Compiler Error C2514

 

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

For the latest documentation on Visual Studio 2017, see Compiler Error C2514 on docs.microsoft.com. 'class' : class has no constructors

The class, structure, or union has no constructor with a parameter list that matches the parameters being used to instantiate it.

A class must be fully declared before it can be instantiated.

The following sample generates C2514:

// C2514.cpp  
// compile with: /c  
class f;  
  
class g {  
public:  
    g (int x);  
};  
  
class fmaker {  
   f *func1() {  
      return new f(2);   // C2514  
   }  
  
   g *func2() {  
      return new g(2);   // OK  
   }  
};   

Show: