Contents Up << >>
How do you express inheritance in C++?
By the ": public" syntax:
class Car : public Vehicle {
//^^^^^^^^---- ": public" is pronounced "is-a-kind-of-a'
//...
};
We state the above relationship in several ways:
- Car is "a kind of a" Vehicle
- Car is "derived from" Vehicle
- Car is "a specialized" Vehicle
- Car is the "subclass" of Vehicle
- Vehicle is the "base class" of Car
- Vehicle is the "superclass" of Car (this not as common in the
C++ community)