You are on page 1of 3

#include <iostream>

using namespace std;

class vehicle
{
protected:

string vehicleName;
public:

void setVehicleName(string vn)


{
vehicleName=vn;
}
virtual void showVehicle ()
{
cout<<"Show vehicle"<<endl;
}
};

class motorVehicle: public vehicle


{
protected:

string vehicleType;
int wheels;
int doors;
public:

void setMotor(string vt,int wh,int d)


{
vehicleType=vt;
wheels=wh;
doors=d;
}

void showVehicle()
{
cout<<"Vehicle Type= "<<vehicleType<<endl;
cout<<"Wheels= "<<wheels<<endl;
cout<<"Doors= "<<doors<<endl;
}

} ;

class car: public vehicle


{
protected:
string carName;
int model;
string color;

public:
void setCarInfo (string n,int m,string col)
{
carName=n;
model=m;
color=col;
}

void showVehicle()
{
cout<<"Car name: "<<carName<<endl;
cout<<"Model: "<<model<<endl;
cout<<"Color: "<<color<<endl;
}
};

class suv: public vehicle


{
protected:
string suvName;
int model;
string make;
string color;
int engSize;

public:

void setSUVinfo (string n,int m,string mk,string col,int eg)


{
suvName=n;
model=m;
make=mk;
color=col;
engSize=eg;
}

void showVehicle()
{
cout<<"Name of SUV: "<<suvName<<endl;
cout<<"Model of SUV: "<<model<<endl;
cout<<"Make: "<<make<<endl;
cout<<"color: "<<color<<endl;
cout<<"Engine Size: "<<engSize<<endl;
}

};

int main()
{
vehicle*v;

motorVehicle mv;
car C1;
suv s;

v->setVehicleName("SAGA");
mv.setMotor("4 wheeler",4,4);
C1.setCarInfo("SCODA",78390004,"GRAY");
s.setSUVinfo("HERRIER",7635634,"USA","Black",222348);
v=&mv;
v->showVehicle();

v=&C1;
v->showVehicle();

v=&s;
v->showVehicle();

You might also like