Difficulty: Easy
Correct Answer: Public members of the base class become public members of derived class.
Explanation:
Introduction / Context:
Inheritance in C++ can be public, protected, or private. The chosen access specifier alters how base-class members are exposed through the derived class's interface. Public inheritance models an “is-a” relationship that preserves the base's public API, enabling substitutability (the Liskov Substitution Principle) and polymorphic use through base references or pointers.
Given Data / Assumptions:
Concept / Approach:
Under public inheritance, the access levels are preserved for the derived interface: base public members remain public in the derived class; base protected members remain protected; base private members are not accessible directly by the derived class (though they exist as part of the object). This preservation is why clients can use a derived object wherever a base is expected. If you change the inheritance to protected or private, the visibility is reduced accordingly, but not under public inheritance.
Step-by-Step Solution:
Verification / Alternative check:
Write a base with a public method and derive publicly; call that method on a derived instance from client code. It compiles, showing the public interface was preserved.
Why Other Options Are Wrong:
A/B — would reduce visibility, not how public inheritance behaves.
C — private members are not inherited as accessible members; they remain hidden.
Common Pitfalls:
Final Answer:
Public members of the base class become public members of derived class.
Discussion & Comments