Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include using namespace std; class Cars { protected: string type; public: Cars ( string _ type ) :type ( _ type ) { }
#include
#include
using namespace std;
class Cars
protected:
string type;
public:
Carsstring type :typetype
void showCarInfo const cout "Type:" type endl endl;
~Cars
;
class ImportedCars : public Cars
private:
string model, country;
public:
ImportedCarsstring type, string model, string country : Carstype modelmodel countrycountry
void showCarInfo const
cout "Type:" type endl;
cout "Model:" model endl;
cout "Country:" country endl endl;
~ImportedCars;
;
class DomesticCars : public Cars
private:
string model;
int warranty;
public:
DomesticCarsconst char type, string model, int warranty: Carstype modelmodel warrantywarranty
void showCarInfo const
cout "Type:" type endl;
cout "Model:" model endl;
cout "Warranty:" warranty "years" endl endl;
~DomesticCars
;
class CarList
private:
Cars carlist;
int carnum;
public:
CarList : carnum
void addcarCars mycar carlistcarnum mycar;
void ShowAllinfo const
for int i ; i carnum; i carlistishowCarInfo;
Destructor for Carlist line
;
int main
CarList mycars;
mycars.addcarnew CarsSedan;
mycars.addcarnew ImportedCarsEV "Tesla", US;
mycars.addcarnew DomesticCarsSUV "Hyundai", ;
mycars.ShowAllinfo;
return ;
Assuming the destructor for CarList is correctly implemented, what is the output of the above code?
Does it print out all the information given for each car? If not, whatsingle modification can you make?write the line number of the code and give the correct modification. What is the modified output?
Give the correct implementation for the destructor for CarList in line Give your implementation in a single line
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started