Question: Write C++ code to modify your Car class to add a (virtual) destructor ( operator is ~ ) for your Car class. A copy of
Write C++ code to modify your Car class to add a (virtual) destructor ( operator is ~ ) for your Car class. A copy of my code is below:
- Class Car { public: //constructors Car(); virtual ~Car(); Car(bool e, bool h, int d, int w); //mutator functions: void setWheels(int w); void setDoors(int d); void setHybrid(bool h); void setElectric(bool e); //accessor functions: bool getHybrid() const; bool getElectric() const; int getWheels() const; void accelerate (int speed); Private: Int wheels; int doors; bool ishybrid; bool is_all_electric; }; Car::Car(); { wheels = 4; doors = 4; ishybrid = false; is_all_electric = false; } Car::Car(bool e, bool h, int d, int w); { wheels = w; doors = d; ishybrid = h; is_all_electric = e; } void setWheels(int w); {wheels = w;} void setDoors(int d); {doors = d;} void setAccelerate(int wheels); {accelerate = wheels;} etc. virtual ~Car() {}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
