Sams Teach Yourself C++ in 21 Days

(singke) #1
Answers 849

D


Exercises

1.class JetPlane : public Rocket, public Airplane
2.class Seven47: public JetPlane


  1. The following is one possible answer:
    class Vehicle
    {
    virtual void Move() = 0;
    virtual void Haul() = 0;
    };


class Car : public Vehicle
{
virtual void Move();
virtual void Haul();
};

class Bus : public Vehicle
{
virtual void Move();
virtual void Haul();
};


  1. The following is one possible answer:
    class Vehicle
    {
    virtual void Move() = 0;
    virtual void Haul() = 0;
    };


class Car : public Vehicle
{
virtual void Move();
};

class Bus : public Vehicle
{
virtual void Move();
virtual void Haul();
};

class SportsCar : public Car
{
virtual void Haul();
};

class Coupe : public Car
{
virtual void Haul();
};

32 0672327112_app_d.qxd 11/19/04 12:30 PM Page 849

Free download pdf