Item-32 Make sure public inheritance models "Is-A"
· ☕ 3 min read
Everything that applies to base classes must also apply to derived classes in public inheritance, for every derived class object is a base class object.
Everything that applies to base classes must also apply to derived classes in public inheritance, for every derived class object is a base class object.
To minimize compilation dependencies, depend on declarations instead of definitions via techniques such as Handle classes and Interface classes.
Limit most inlining to small, frequently called functions to facilitate debugging and binary upgradability, minimize potential code bloat, and maximize the chances of greater program speed.
Exception-safe functions leak no resources and allow no data structures to become corrupted, even when exceptions are thrown. Such functions offer the basic, strong, and nothrow guarantees.
Avoid returning handles to object internals to increase encapsulation, help const
member functions act const
, and minimize the creation of dangling handles.