your right if we want car with no radio.This suggests that the root of your difficulty is that Radio should not be a member of Car at all (after all, how would define CarWithNoRadio, then?)
But i am not agree on storing radio object in each derived car.
What if we want to derive some car from luxury car & want some diff. radio in that it will create same probelm as first post
if we want car with radio & no radio. I think it shoud go with one more abstrract level 1)Car with radio 2)Car without radio.
Car with radio abstract class will store the Radio reference
VinodCode:class Car { }; // this is an abstract base class - no member data class CarwithRadio: public Car { public: Car(Radio*); protected: Radio* } class CarwithoutRadio : { } class LuxuryCar : public CarwithRadio { public: LuxuryCar(Radio*); }




Reply With Quote