#include<iostream>
usingnamespacestd;
classVehicle{
public:
virtualvoidRun(){cout<<"Vehicle::Runcalled\n";}
virtualvoidStop(){cout<<"Vehicle::Stopcalled\n";}
};
classmotorcar:publicVehicle{
voidRun(){cout<<"motorcar::Runcalled\n";}
virtualvoidStop(){cout<<"motorcar::Stopcalled\n";}
classbicycle:publicVehicle{
virtualvoidRun(){cout<<"bicycle::Runcalled\n";}
voidStop(){cout<<"bicycle::Stopcalled\n";}
classmotorcycle:publicbicycle,publicmotorcar{
voidRun(){cout<<"motorcycle::Runcalled\n";}
voidStop(){cout<<"mototrcycle::Stopcalled\n";}
voidmain(){
Vehicleve;
bicyclebi;
motorcarmo;
motorcyclemocy;
Vehicle*pclass=&ve;
pclass->Run();
pclass->Stop();
pclass=&bi;
pclass=&mo;
}
#include<iostream>
usingnamespacestd;
classVehicle{
public:
virtualvoidRun(){cout<<"Vehicle::Runcalled\n";}
virtualvoidStop(){cout<<"Vehicle::Stopcalled\n";}
};
classmotorcar:publicVehicle{
public:
voidRun(){cout<<"motorcar::Runcalled\n";}
virtualvoidStop(){cout<<"motorcar::Stopcalled\n";}
};
classbicycle:publicVehicle{
public:
virtualvoidRun(){cout<<"bicycle::Runcalled\n";}
voidStop(){cout<<"bicycle::Stopcalled\n";}
};
classmotorcycle:publicbicycle,publicmotorcar{
public:
voidRun(){cout<<"motorcycle::Runcalled\n";}
voidStop(){cout<<"mototrcycle::Stopcalled\n";}
};
voidmain(){
Vehicleve;
bicyclebi;
motorcarmo;
motorcyclemocy;
Vehicle*pclass=&ve;
pclass->Run();
pclass->Stop();
pclass=&bi;
pclass->Run();
pclass->Stop();
pclass=&mo;
pclass->Run();
pclass->Stop();
}