2.1 Default Constructors' Construction Operation The Default Constructors will only be generated by the compiler when needed. Only when the compiler needs Default Constructionor, a constructor will only be synthesized, only the following four situations will have a Nontrol DEFAULT CONSTRUctor, and the rest is Trivial default constructor
1) Member Class Object with Default Constructor If a class does not define its own constructor, but contains a member object, and the latter contains a default constructor, then the sub-class of implicit default constructor is nontrivial, the compiler will synthesize a constructor. Note is The synthetic constructor only meets the needs of the compiler, not the needs of the programmer (only the things you want to do). If you contain multiple Class Member Object, the Constructor requires initialization operations to invoke each constructors in accordance with Member Object in the Class of the Class. 2) Base Class with Default Constructor If the constructor is not defined, the compiler will generate a NontriVial Constructor, first call the corresponding base class's constructor. If the user defines the constructor, then the compiler will expand him, and the handout calls all than To add the program code of Default Constructionors. 3) Class of Virtual Function: Because the compiler must initialize VPTR and VTABLE! 4) Class: In this case, if you want to access the top Class of Class by a pointer, you must complete it through the "pointer to the base class". Pa -> _ vbcx-> i = 1024; _vbcx is done when the Class Object is created.
2.2 En enough operation by the COPY Constructor: Object as the Copy Constructor: Object As the Return value of the function parameter transfer function is Object to initialize the most initial value with a similar entity, if the class does not define the CONSTRUctor, then the compiler may synthesize one Copy Constructor - Memberwise Initialization, or use Bitwise Copy
Do not, Bitwise Copy is consistent with the situation of the above Default Construcotr, 1) Contains a MEMBER OBJECT in the class, while the lass's Class has a Copy Constructor 2) When the class inherits a base class, and Base Class has a COPY Constructor 3) Class contains Virtual Funciton 4) Class White Cape inherits a string chain, which has Virtual base classes. The following two are more complicated because the object assignment between Derived Class and Base Class. You must ensure the correctness of their VPTR.