Inheritance

Inheritance allows one class to acquire properties of another.

class Vehicle {
  public:
    void start() {
      cout << "Engine on\n";
    }
};

class Car : public Vehicle {};

Car inherits start() from Vehicle.

← PrevNext →