Suppose we obtained a class B as derived from a base class A. The inherited members by the class B are filtered by the class A and become as follows:
Inher. type | Class member types |
---|---|
private |
|
protected |
|
public |
|
In other words, the members access modifies as follows:
Base class | Inheritance | Derived class |
---|---|---|
private: X protected: Y public: Z |
private | X is inaccessible private: Y private: Z |
private: X protected: Y public: Z |
protected | X is inaccessible protected: Y protected: Z |
private: X protected: Y public: Z |
public | X is inaccessible protected: Y public: Z |
The public and private inheritance is schematically shown on the following picture