Base&
is handed a Derived&
instead). Polymorphism occurs when a collection of related classes can be used via the protocol they all have in common. This allows one component of a system to deal with other components at the highest level of abstraction possible (the base class) and ignore any irrelevant details (of the derived class).
Type inheritance is also known as subtyping; deriving a class from a public base class states that the new class is a subtype. This statement places important constraints on the base class and the derived class. If these constraints are not met, serious errors can occur later. Compilers can't catch many of these errors.
If you want to share only portions of a base class' protocol, make the class private and reexport the members you want to make public (or factor that partial protocol out into a separate base). Use public base classes only when you need polymorphism.
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Generated with WebMaker