Today is nothing to see the C + + constructor principle, by the way to make a note, after all, good memory is not as bad as the written, nonsense not much to say, straight to the subject.
The C + + constructor principle boils down to a few of the following:
1. If a subclass does not have a constructor defined, the child class defaults to calling the parent class parameterless constructor.
2, if a subclass defines a constructor, regardless of whether the constructor of the subclass has parameters or no arguments, when the subclass is created, the constructor that calls the parent class is not displayed, and the parameterless constructor of the parent class is called first, and the subclass's own constructor is called.
3, when creating subclasses, if the subclass does not display the constructor that calls the parent class, the parent class defines its own parameterless constructor, then the parent class is called without a parameter.
4. When creating a subclass object, if the subclass does not display a constructor that calls the parent class, and the parent class simply defines the constructor with the parameter, an error is made. The correct approach is that the subclass must display a parameterized constructor that invokes the parent class.
5. When creating a subclass object, the subclass must initialize the parent class constructor with the initialization class table if the child class displays the constructor that called the parent class.
Above, it boils down to that the subclass must first call the parent class's constructor, and then call its own constructor.
C + + constructor principles