What is the order of construction and destruction of objects in an inheritance hierarchy?
Last updated
Construction goes base-to-derived: base constructors (in declaration order of bases), then members (in declaration order, not initializer-list order), then the derived body.
Destruction runs in exactly the reverse order, derived-to-base.
Deleting via a base pointer needs a
virtualdestructor (otherwise undefined behavior). Virtual calls inside a base constructor resolve to the base version.