In C++, functions which the compiler will generate automatically if not declared
In the C++programming language, special member functions[1] are functions which the compiler will automatically generate if they are used, but not declared explicitly by the programmer.
The automatically generated special member functions are:
In these cases the compiler generated versions of these functions perform a memberwise operation. For example, the compiler generated destructor will destroy each sub-object (base class or member) of the object.
The compiler generated functions will be public, non-virtual[3] and the copy constructor and assignment operators will receive const& parameters (and not be of the alternative legal forms).[4]
Example
The following example depicts two classes: Explicit for which all special member functions are explicitly declared and Implicit for which none are declared.
^Except for the destructor if a base class already has a virtual destructor.
^Similarly, the move constructor/assignment operators will receive && parameters instead of the alternatives.
^ISO/IEC (1998). International Standard ISO/IEC 14882: Programming languages—C++ = Languages de programmation—C++ (1 ed.). ISO/IEC. pp. §12. OCLC71718919.