Understanding access modifiers in C++
This easy question tests your grasp of C++ access control—specifically how private, public, and protected visibility rules govern what code can and cannot access. It is a foundational topic that interviewers use to confirm you understand class boundaries and encapsulation, even if the question itself is straightforward.
To answer correctly, you need to trace which members are accessible from the call site, which attempts to access them will fail at compile time, and what the output actually is. The question rewards precision: knowing not just the concept but also how C++ enforces these rules and what error or output results.
- Class member visibility and scope
- Compile-time vs. runtime errors
- Inheritance and access control