The compiler does not always automatically generate a default constructor for us when the class does not display a declaration constructor, and the compiler will automatically generate a default constructor for us in the following 4 cases:
1. In a class where a class member contains a default constructor, the compiler automatically generates a default constructor for the class, automatically inserts the code, and invokes the member's constructor;
2. The base class contains a default constructor, which automatically generates a default constructor for the class, automatically inserts code, and invokes the constructor of the base class;
3. When a class contains a virtual function, it is necessary to synthesize a default constructor for the class because the compiler generates a virtual function table vtable for the class and generates a vptr for the class object to that vtable;
4. When virtual inheritance occurs;
In addition to these four cases, the compiler does not automatically generate default constructors for us, such as integers, pointers, arrays, etc. in a class, because the initialization of these members is not necessary for the compiler, and all are not automatically initialized, and the initialization of those members requires the programmer to display Write code implementation;
scenario where the compiler generates a default constructor