Sams Teach Yourself C++ in 21 Days

(singke) #1
Polymorphism 489

14


Exercises ........................................................................................................



  1. Show the declaration for a class JetPlane, which inherits from Rocketand
    Airplane.

  2. Show the declaration for Seven47, which inherits from the JetPlaneclass
    described in Exercise 1.

  3. Write the code that derives Carand Busfrom the class Vehicle. Make Vehiclebe
    an abstract class with two pure virtual functions. Make Carand Busnot be abstract
    classes.

  4. Modify the code in Exercise 3 so that Caris an abstract class, and derive
    SportsCarand Coupefrom Car. In the Carclass, provide an implementation for
    one of the pure virtual functions in Vehicleand make it nonpure.

Free download pdf