11.9. Summary of Derivation Options

Table 11.1 summaries access levels for public, protected, and private derivation.

Table 11.1. Summary of access levels with inheritance
Base Class Member Derivation Access Level Derived Class Member Users of Derived Class
private private or not accessible not accessible
protected or
public
public or private private not accessible
protected
protected public or protected not accessible
protected
public protected protected not accessible
public public public public

Public derivation is the most common form of inheritance. Public derivation creates a subtype of a base class and provides the foundations for polymorphism and dynamic binding with class hierarchies. With public derivation, you can reuse code from base ...

Get Navigating C++ and Object-Oriented Design 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.