Compiler Error C2558

'identifier' : no copy constructor available

No copy constructor was defined to copy the specified class.

A copy constructor is used to initialize an object with the values of another object of the same type — that is, to make a copy of the object.

If no copy constructor is provided, the compiler will generate a default copy constructor. A default copy constructor is not generated by the compiler if any user-defined copy constructor has been defined.

This error can occur if a private copy constructor is declared. In most cases, a class with a private copy constructor should not be copied.

Declaring a private copy constructor is a common C++ programming technique used to prevent the direct use of certain classes. For instance, a class may be useless by itself or require another class in order to work properly. In this case, you can prevent direct use of a class by declaring the copy constructor to be private.

Tips