+ 1

Can someone explain to me, why this isn't working?

The class C should have access to the protected variables of its base class, shouldn't it? https://code.sololearn.com/cTqDrxYCo5cn/?ref=app

6th Jun 2019, 12:22 PM
MrNick7373
2 Respostas
+ 2
Accessing the protected part can only be done by a pointer to, reference to, or an object of the derived class. ( or classes derived from that class ) In this case A* is not a pointer to the derived class, but to the base class. Normal accessing rules apply. ( can't access private and protected from the outside ) http://eel.is/c++draft/class.protected
6th Jun 2019, 1:40 PM
Dennis
Dennis - avatar