Constructors and Destructors for Derived Classes
When an object of a derived class is created, both its base and derived parts might need initialization. The base part of the derived class object and its derived part are created in a rigid sequence. It is important to understand this sequence to avoid potential syntactical and performance problems.
The issues of object construction under inheritance are very similar to the issues of object construction under class composition. For composition, the object data members are created (and their constructors are called) before the composite class constructor is executed. If the appropriate constructors do not exist, an attempt to create a composite object might result in a syntax error. If the appropriate ...
Get Core C++ A Software Engineering Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.