0

Can protected data accessed in derived class? If yes...then how??

22nd Dec 2016, 5:55 PM
Sumit Lokhande
Sumit Lokhande - avatar
2 Answers
+ 1
What do you mean how? A protected member of a base class is usable in the derived class, just as if it was public to that derived class only. class Animal { protected: short legs; }; class Dog : public Animal { public: Dog() { legs = 4; } };
23rd Dec 2016, 2:14 AM
Cohen Creber
Cohen Creber - avatar
0
definitely only private you cant use in derived class. you can use direct as you are using in base class. but form the another function you cant use.
22nd Dec 2016, 6:27 PM
himanshu yadav
himanshu yadav - avatar