I have extended previous example in other thread to understand polymorphism in oop
is it polymorphism in oop ? What will be the simple definition of polymorphism ?
C:
#include <iostream>
#include <string>
using namespace std;
class Vehicle {
public:
void WhoUseVehicle() {
cout << "Person use vehicles\n" ;
}
};
class PoliceCar : public Vehicle {
public:
void WhoUseVehicle() {
cout << "Police officer use Police car \n" ;
}
};
class SportCar : public Vehicle {
public:
void WhoUseVehicle () {
cout << "Sport player Use sport Car\n" ;
}
};
int main() {
Vehicle mycar;
PoliceCar ranger;
SportCar jaguar;
mycar.WhoUseVehicle();
ranger.WhoUseVehicle();
jaguar.WhoUseVehicle();
return 0;
}