switch (myVehicle->type) {This is difficult and error-prone to maintain, when new types of vehicles are added...case CAR:
x = stopCar();
break;
case PLANE:
x = stopPlane();
break;
case BIKE:
x = stopBike();
break;
default:
error("Invalid");
}
x = myVehicle->stop();In C++, the variable myVehicle would have been declared to be of type "reference to an instance of class Vehicle, or one of its subclasses":
Vehicle* myVehicle;
© Ericsson Telecom AB, 1995, Stockholm, Sweden