English
Summary
Conclusions
Public inheritance defines a substitution contract. A virtual call depends on the actual type. Ownership and polymorphism require separate decisions. Slicing changes the object itself, not just the call path.
Self-check questions
- When does an “is-a” relationship justify inheritance?
- How does the static type differ from the dynamic type?
- Why is a virtual destructor needed?
- Why doesn’t a vector store the derived part?
- What does override check?
- How does virtual behave in a base constructor?
- In what order is a hierarchy destroyed?
- Why is a protected method better than open access to a field?
- How does a failed dynamic_cast of a pointer differ from that of a reference?
- Why are exceptions caught by const reference?
- What does final mean for a class and for a method?
- What are the risks of a static_cast to a derived type?
- Why isn’t the vtable diagram an ABI guarantee?
- How does using Base::Base affect new fields?
- When does dynamic_cast suggest changing the interface?