Is it possible to write a C++ class that controls an object that can be of a derived type, without using a pointer?
Example
class Car {
public:
void Honk();
};
class RedCar : public Car {}
class CarController {
public:
CarController(Car car);
Car car;
void Honk();
}
void CarController::Honk(){
this->car.Honk();
}
RedCar redcar;
CarController controller(redcar);
controller.Honk();