May 2012
Intermediate to advanced
679 pages
16h 56m
English
Earlier we have discussed access specifiers public and private. You may wonder why we are discussing the third access specifier, protected, in the end.
There is a simple reason for that. For all practical purposes, protected members are as good as private members within the class. It means that for any method of the class, it is freely available. For any other method or global function, it is not available (accessible). Hence, in simple situations you can replace it with “private”.
The protected access specifier becomes distinctive when we derive one class from the other. We will study this access specifier in detail and use it in chapters on inheritance.
Read now
Unlock full access