The usual: Record the details, wait for the spare, and then organize.
1:const,static,const static member initialization.
1. Const member: can only be initialized in the initialization list after the constructor
2. Static member: Initialization is outside the class and does not add static adornments.
3. const STATIC MEMBER: The class has only one copy, and the value cannot be changed. Therefore, it can be initialized in a class, or it can be initialized outside of the class like static.
2: Copy assignment function and copy constructor.
1, copy the assignment function.
1) The return value is a reference to the left type.
2, copy constructor.
1, the usual principal function should be: Copy all non-static class members.
2, the system is constructed by default. But try to do it yourself (unless the class copy is simple).
3, the parameter must be a reference. Doing so will result in recursive calls and eventually crashes.
3, copy assignment functions and copy constructors are required by each other. That is, if you need to define a copy assignment function, you must define a copy constructor. Vice versa.
3:explicit keyword.
1, the constructor that identifies this keyword must be displayed for use. cannot be called implicitly.
4: destructor.
1, the destructor function body does not carry out the destruction of class members. Instead, the member is destroyed when the destructor body is complete.
2, for pointers, the destroy function destroys the pointer itself only, and does not destroy the object pointed to by the pointer. Therefore, you need to delete/free the pointer in the destructor
3, in principle, a class has a destructor, it should also have its own copy constructor and copy assignment function.
5: Move function.
1, it is divided into moving function and moving assignment function.
2, move function (including assignment) feature: "Stealing" the data of the source object. Causes the source object to enter an unpredictable situation.
3, the use of mobile functions will improve the efficiency of operation. It should be noted, however, that if the object after "stealing" data is still referenced by other threads and functions, it can cause unpredictable errors.
C + + Detail series (0): Fragmented records