79595000

Date: 2025-04-27 12:10:14
Score: 1.5
Natty:
Report link

The code doesn't cause an error because:

  1. _name is protected in Person.

  2. teacher is a derived class of Person, so it can access protected members of Person.

  3. This is intentional design in C++ to allow derived classes to interact with base class members while still restricting access from outside the hierarchy.

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: Yaman Hassan