English
Topic 10. Inheritance, virtual functions and polymorphism
Goal: learn to apply the concepts of the topic “Inheritance, Virtual Functions and Polymorphism” in console projects; justify the invariants and the contract of operations, and test ordinary and edge cases.
Lecture contents
- The “is-a” relationship and a hierarchy — The “is-a” relationship and the contract of a base type · Constructing and destroying a hierarchy
- protected and the exception hierarchy — Access, protected and reuse · The exception hierarchy and catching
- Virtual functions — Virtual functions, override and hiding · A virtual destructor and ownership · Polymorphic collections and slicing · RTTI and checked conversions · The virtual function table model
- Case studies and common mistakes — A substitution audit using a delivery example · A diagnostic route for an override error · Testing a hierarchy and the limits of responsibility · A decision table for how to pass an object · Why a protected field spreads the invariant across the whole hierarchy · Specializing the reaction without checking the error text