suppose a class has private data members but the setters and getters are in public scope. If you inherit from this class, you can still call those setters and getters — enabling access to the private data members in the base class. How is this possible since it is mentioned that a derived class cannot inherit private data members
Share
A derived class doesn’t inherit access to private data members. However, it does inherit a full parent object, which contains any private members which that class declares.