Consider the inheritance of classes from Exercise R-2.6, and let d be an object variable of type
Question:
Consider the inheritance of classes from Exercise R-2.6, and let d be an object variable of type Horse. If d refers to an actual object of type Equestrian, can it be cast to the class Racer? Why or why not?
Data from in Exercise R-2.6
Draw a class inheritance diagram for the following set of classes.
• Class Goat extends Object and adds a member variable tail and functions milk and jump.
• Class Pig extends Object and adds a member variable nose and functions eat and wallow.
• Class Horse extends Object and adds member variables height and color, and functions run and jump.
• Class Racer extends Horse and adds a function race.
• Class Equestrian extends Horse and adds a member variable weight and functions trot and is Trained.
Step by Step Answer:
Data Structures And Algorithms In C++
ISBN: 9780470383278
2nd Edition
Authors: Michael T. Goodrich, Roberto Tamassia, David M. Mount