Base Class and Derived Class

In this lesson, we'll be learning about how a base class attributes are available to the derived classes and how to define base and a derived class.

In the last lesson, we have seen that Vehicle class attributes are shared by the other two classes(Car and Ship).

Vehicle as a Base Class

We can consider the Vehicle class as a base class as it has common attributes.

Derived Classes

Cars and Ships are considered as derived classes as they’re inheriting properties from vehicle class.

Modes of Inheritance

There are three modes of class inheritance: public, private and protected. The basic syntax for inheritance is given below:

class derivedClassName : modeOfInheritance baseClassName

We use the keyword public to implement public inheritance.