9.5 PROTECTED DERIVATION

C++ allows us to use third access modifier namely protected. Such a derivation may be called as protected derivation. Here, base class public members turn in to protected members in the derived class. Protected members remain protected, whereas private members are not accessible. When we have three or four levels of inheritance hierarchy, use of protected becomes very useful.

Table 9.1 summarizes the access of the base class members in the derived class under various derivations.

 

Table 9.1 Access in a Derived Class

images

 

Box 9.1 clarifies the nomenclature access specifiers and modifiers.

Box 9.1 Access Specifiers and ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.