Compiler Error C2534


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

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

identifier' : constructor cannot return a value

A constructor cannot return a value or have a return type (not even a void return type).

This error may be fixed by removing the return statement from the constructor definition.

The following sample generates C2534:

// C2534.cpp  
class A {  
   int i;  
   A() { return i; }   // C2534