Coupon Accepted Successfully!


The protected keyword

The access mechanism of protected keyword is same as private keyword. We cannot access protected section members from outside the class by any object.

The following example clears the above concept:

8.4 Write a program using class to declare member variable and function under protected section and make an attempt to access them using object.



Note: The above program gives an error A::num and A::display() are not accessible.


The protected keyword is frequently used in inheritance of classes. Its detailed description is given Chapter 11.

Test Your Skills Now!
Take a Quiz now
Reviewer Name