+ 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
2 Answers
+ 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