+ 1

Can object of derived class access protected member functions of its base class?

28th Feb 2017, 6:03 AM
Prabhat Rao
Prabhat Rao - avatar
3 Réponses
+ 2
If you could, what would be the benefit of using public? You can access base class properties and methods in you derived class itself (in methods for example), but you can't use them on a object of the derived class.
28th Feb 2017, 6:23 AM
qobus
+ 1
I'm pretty sure you know the answer yourself
28th Feb 2017, 6:07 AM
Zilvinas Steckevicius
Zilvinas Steckevicius - avatar
+ 1
you create protected member variables because you specifically want them to be used, not in the parent but, in the child class. if you try to assign or use protected varables within the same class you should get errors.
28th Feb 2017, 7:08 AM
Michael Szczepanski
Michael Szczepanski - avatar