+ 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?
3 ответов
+ 2
Therefore b and c are accessible from B?? Right?
+ 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;
}
+ 1
in private inheritance
private members remains unaccessible to derived class
whereas protected and public members become private members in derived class