1protected://means all sub classes and base class can access these functions and variables butcan't be accessed outside classes
2public://Pubic methods and variables can be accessed inside and outside of the class
3private://only entity class can read and write the variables exeption is friend
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};