November 2001
Beginner
1128 pages
29h 12m
English
The RatedPlayer example of inheritance is a simple one. Objects of the derived class use the base class methods without change. But you can encounter situations in which you want a method to behave differently for the derived class than it does for the base class. That is, the way a particular method behaves will depend upon the object that invokes it. This more sophisticated behavior is termed polymorphic (“having many forms”) because you can have multiple behaviors for a method, depending upon the context. There are two key mechanisms for implementing polymorphic public inheritance:
Redefining base class methods in a derived class
Using virtual methods
It's time for another example. You have leveraged your experience ...