Suppose that I have this piece of code:
class Vehicle {
virtual const char* media() const = 0;
virtual unsigned speed() const = 0;
} V, *PV;
class LandVehicle : public Vehicle {
const char* media() const override{ return "Land";}
} L, *PL;
class Train : public LandVehicle{
virtual unsigned speed() const override {return 130;}
} T, *PT;
I have a few questions about it :D
1) LandVehicle doesn't implement speed(). is that an error and if so, what kind of error? or does it just make it an abstract class as well ?
2) is the keyword override in class LandVehicle in method media() used correctly? as a derived class from an abstract class is it really overriding the method?
3) same as 2 for override in Train's speed() method.
4) is Train a concrete class now?
5) is it necessary to add the keyword virtual in the declaration of LandVehicle's media() method?
6) if I add this method in Train class:
const char* media() const{ return "Just a train";}
does it hide LandVehicle's media() or does it override it ?
7) after adding the method in 6, can LandVehicle's media() be accessed in Train class?