Order of Destruction
When an object goes out of scope or is deleted, the sequence of events in its complete destruction is as follows:
-
The class’s destructor is called, and the body of the destructor function is executed.
-
Destructors for nonstatic member objects are called in the reverse order in which they appear in the class declaration. The optional member initialization list used in construction of these members does not affect the order of construction or destruction. (For more information about initializing members, see Initializing Bases and Members.)
-
Destructors for nonvirtual base classes are called in the reverse order of declaration.
-
Destructors for virtual base classes are called in the reverse order of declaration.