C++ Inheritance Access

Access Specifiers

You learned from the Access Specifiers chapter that there are three specifiers available in C++. Until now, we have only used public (members of a class are accessible from outside the class) and private (members can only be accessed within the class). The third specifier, protected, is similar to private, but it can also be accessed in the inherited class: Continue reading C++ Inheritance Access

C++ Inheritance

Inheritance

In C++, it is possible to inherit attributes and methods from one class to another. We group the “inheritance concept” into two categories:

  • derived class (child) – the class that inherits from another class
  • base class (parent) – the class being inherited from

To inherit from a class, use the : symbol.

In the example below, the Car class (child) inherits the attributes and methods from the Vehicle class (parent): Continue reading C++ Inheritance