+ 1

Which members of A are accessible from B??? class A{ int a; protected: float b; public: char c; }; class B : private A{ }; I think it should be none as A is private.. but its wrong!!

What's the correct answer?

9th Sep 2016, 10:09 AM
Soutik
Soutik - avatar
3 ответов
+ 2
Therefore b and c are accessible from B?? Right?
9th Sep 2016, 3:20 PM
Soutik
Soutik - avatar
+ 1
A is not private. B inherits from A and that inheritance is private. It means that all members inherited from A (which are the protected and public members of A, in other words b and c) are private in B. To make sure you understand, the B class is equivalent to this: class B { private: float b; char c; }
9th Sep 2016, 10:42 AM
Zen
Zen - avatar
+ 1
in private inheritance private members remains unaccessible to derived class whereas protected and public members become private members in derived class
9th Sep 2016, 2:30 PM
Shaurya Agnihotri