Ditai C++ Study Notes-Lesson 46-Construction and Deconstruction in Inheritance

The subclass constructor must initialize the inherited members
(1) initialize directly through the initialization list or assignment
(2) call the parent class constructor to initialize

The calling method of the parent class constructor in the subclass
(1) Default call: applicable to no-argument constructors and constructors with default parameters
(2) Display call: Called through the initialization list, applicable to all parent class constructors

The calling sequence of the constructor when the object is created
(1) call the constructor of the parent class
(2) call the constructor of the member variable
(3) call the constructor of the class itself

Guess you like

Origin blog.csdn.net/cj532419842/article/details/115310445