Course Object Oriented Programming

Inheritance in C++ (public)

Course's Page 13 min Text by
User Image
Abacate

In this lesson, you will see in practice how Inheritance works in C++, more specifically, the public inheritance.

Syntax

The basic syntax is shown below:

class <derived_class> : [<access>] <base_class> {
    //code of the derived class
};

Example

Now let's take a look in how this syntax is used inside an example.

class A {
public:
    int x;