Assigned Reading:
Slides As Shown:
Topics Covered:
An example of private derivation is deriving a Package class from the Box class we've been discussing:
Package.h
Package.cpp
ptest1.cpp
ptest1.txt
ptest2.cpp
ptest2.txt
An example of multiple inheritance is having our GUI race course derive from both the GTKmm Window class and the RaceCourse class from Project~2. Then, a GUIRaceCourse object is both a Window and a RaceCourse, instead of a Window that contains a RaceCourse. It is debatable which approach makes more sense.
Examples of the Box class using virtual identify(). The only change needed is to add the keyword "virtual" to declaration of identify() in the Box class definition: Box.h.
Some test programs using the virtual identify() function: vtest0.cpp, vtest1.cpp, and vtest2.cpp. Note that the end of vtest2.cpp is a total hack that rewrites the virtual function table pointer of cc to make it point to the base class virtual function table. (Don't do try this at home.)