22.9. Parent and child constructors and destructors

When a class object is constructed, the following sequence takes place.

  1. Memory storage for the object is allocated (e.g. enough bytes for the object’s data fields are allocated in memory).

  2. The default constructor of the parent class (if any) is called, unless you explicitly request some other parent constructor in your initializer list.

  3. The constructors for each of the class member objects are executed (in the order of the member classes’ declaration); if there is no initializer list the default constructors are called, but you can request special constructors in your initializer list.

  4. The class constructor code is executed.

When a class object is destroyed the following sequence takes place. ...

Get Software Engineering and Computer Games 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.