c 2b 2b public inheritance not getting protected

Solutions on MaxInterview for c 2b 2b public inheritance not getting protected by the best coders in the world

showing results for - "c 2b 2b public inheritance not getting protected"
Samuel
26 Oct 2018
1class A 
2{
3public:
4    int x;
5protected:
6    int y;
7private:
8    int z;
9};
10
11class B : public A
12{
13    // x is public
14    // y is protected
15    // z is not accessible from B
16};
17
18class C : protected A
19{
20    // x is protected
21    // y is protected
22    // z is not accessible from C
23};
24
25class D : private A    // 'private' is default for classes
26{
27    // x is private
28    // y is private
29    // z is not accessible from D
30};