Inheritance
Title
Question
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 13px;">Can we use private members of base class which is stored in public member of same class in the derived class as you done in this tutorial using sub1,sub2,sub3 which is stored in public member total and then access this total in derived class?Cann't we use here access specifier protected?</span>
Advanced-Cpp Inheritance 04-05 min 50-60 sec
Answers:
Please read the Data hiding rules:
1. Private members are not directly accessible by any derived classes.
2. Protected members always remain protected in the public and protected derivation of the derived classes, and change to private in private derivation.
3. Public members can be accessed outside the base class. Public members are inherited as public, protected, and private in the derived classes, based on the derived class derivation.
-nags
Login to add comment