October 2004
Intermediate to advanced
240 pages
6h 22m
English
Override responsibly: When overriding a virtual function, preserve substitutability; in particular, observe the function’s pre- and post-conditions in the base class. Don’t change default arguments of virtual functions. Prefer explicitly redeclaring overrides as virtual. Beware of hiding overloads in the base class.
Although derived classes usually add more state (i.e., data members), they model subsets, not supersets, of their base classes. In correct inheritance, a derived class models a special case of a more general base concept (see Item 37).
This has direct consequences for correct overriding: Respecting the inclusion relationship implies substitutability—operations that apply to entire ...
Read now
Unlock full access