Appearance Quote by Bjarne Stroustrup
“Destructors for virtual base classes are executed in the reverse order of their appearance in a depth-first left-to-right traversal of the directed acyclic graph of base classes.”
About This Quote
Source Book: The C++ Programming Language, 4th edition, 2013
Destructors for virtual bases run in reverse order of a depth‑first left‑to‑right traversal of the inheritance graph.
In simple terms: Virtual base destructors run opposite to their appearance order.
Understand and respect the order when designing class hierarchies.
Themes
Mood
Type
When to use this quote
- Implementing polymorphic libraries
- debugging destructor crashes
- ensuring proper resource release
Key Concepts
Questions to Reflect On
- How does this order affect resource deallocation?
- When might you need to override this behavior?
If multiple inheritance is deep, the order can be hard to predict, leading to subtle bugs.