class Car float getCost virtual void addEngine Engine engine class Car

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
class Car
{
...
float getCost();
virtual void addEngine(Engine* engine);
...
};
class CarDecorator
{
protected:
Car* mCar;
public:
CarDecorator(Car* car) : mCar(car) {};
void setCar(Car* car) {mCar = car;}
...
virtual float getCost() {return mCar->getCost();}
virtual void addEngine(Engine* engine) {mCar->addEngine(engine);}
...
};