Access Specifiers & The Inheritance Visibility Matrix
Complete breakdown of private, protected, and public modifiers across derived classes.
Mock tests for SSC, Banking, Railways, UPSC & state exams
Real exam pattern, negative marking and a worked solution for every question.
Access specifiers (or access modifiers) govern which parts of an application can read or modify class members. They form the primary boundary of Encapsulation.
1. What Are Access Specifiers?#
• Private: Accessible ONLY within the defining class. Inaccessible to subclasses and external callers.
• Protected: Accessible within the class, by derived subclasses, and within the same package.
• Public: Accessible from any class anywhere in the application.
2. The Official Inheritance Visibility Matrix#
This famous matrix (reproduced directly from Page 5 of the curriculum) defines what happens to base class members under different C++ inheritance modes:
| Base Class Member | Public Inheritance | Protected Inheritance | Private Inheritance |
|---|---|---|---|
| Public Member | Public in derived class | Protected in derived class | Private in derived class |
| Protected Member | Protected in derived class | Protected in derived class | Private in derived class |
| Private Member | Not Accessible (Hidden) | Not Accessible (Hidden) | Not Accessible (Hidden) |
The 5 Inheritance Architectures (Visual Topology)
Exact structural blueprints as defined in standard SDE placement examinations.
Direct linear lineage. Exactly one derived class inherits from one base class.
One derived class inherits features directly from two or more parent classes.
Chained transitive inheritance. Class C inherits from B, which inherits from A.
One parent class serves as the common base for multiple independent child classes.
Combines hierarchical and multiple inheritance topologies, creating complex polymorphic structures.
Notice that Private base members are NEVER directly accessible in the derived class, regardless of whether you inherit publicly, privately, or protected! They are always hidden.
Practise placement aptitude on the real test pattern
TCS NQT, Infosys, Wipro, Accenture and Cognizant style mocks with section-wise analysis.
Test Your Concept Mastery
Verify your retention on: Access Specifiers & The Inheritance Visibility Matrix
If a derived class inherits privately from a base class, what access level does a public base member receive in the derived class?
Ready for a full proctored assessment?
Take a free quick test on the real exam pattern, with a worked solution for every question.