In general, for a user-defined class type, the following four functions are automatically generated by the compiler when the user does not have a custom condition:
1. Default constructor
2. Copy constructor
Someclass::someclass (const SomeClass &);
3. Copy assignment operator
SomeClass & someclass::operator= (const SomeClass &);
4, destructor
For C++11, a further two additions were made:
5. Move constructor
Someclass::someclass (SomeClass &&);
6. Move Assignment
SomeClass & Someclass::operator= (SomeClass &&);
To keep in mind the prototypes of these functions (input parameters, return types), there are several rules about when the compiler will not generate the above default member functions:
The compiler will not generate a default constructor if the user customizes any form of the constructor (even if it is a copy constructor)
If a destructor, or copy constructor or copy assignment operator is defined, the compiler will not generate the default move constructor and move assignment
If you define move Construcor or move assignment, the compiler will not generate a default copy constructor or copy assignment operator.
Finally, in the c++11 there is a very chic lazy way,
Someclass::someclass (const SomeClass &) = default, which means that the user needs the compiler to generate the member function by default, which is only valid for the above six functions.
Default member functions in C + +