I have a specific class structure in mind, though I feel like it could become a little messy when the project gets bigger. The general idea is the following:
There is a class for all possible vehicles with basic implementations that do not change for any vehicle, regardless of its specific type. Then, for all the cars, there should be an interface with functions only cars can have. This interface is purely virtual though. Then, any car can implement these functions as needed. I included a very simplistic code example below:
class Vehicle { //general class for a vehicle
public:
void move() {
std::cout << "I moved\n";
}
void crash() {
std::cout << "I crashed\n"
}
};
class CarInterface : public Vehicle { //purely virtual interface for cars
public:
virtual void refuel() = 0;
};
class Ferrari: public CarInterface { //implementation: one specific car
public:
void refuel() override {
std::cout << "I use ferrari fuel\n"
};
};
In the c++ guidelines, it says you should distinguish between implementation inheritance and interface inheritance. Does this still fulfill that requirement?