The visibility of a class member variable or member function determines from where that variable can be accessed/modified or from where the member function can be called.
There are three classifications of visibility:
Visibility is implemented through labels and all member variables or member functions which appear after a visibility label have that visibility. For example, the standard grouping is to list all private members first, followed by all public members, as is demonstrated here:
class AClass { private: int n; double x, y; public: const int N; int f(); int g( double, double ); };
It is possible to use multiple labels within a class declaration, however this can only obfuscate code.
In general, is is preferable to declare a member variable to be private as opposed to protected. Declaring a member variable to be protected breaks encapsulation, as now the restrictions on the possible values of that variable must be checked in multiple places. A modification at the top-level class may not be reflected in the operations on that variable in the derived classes.
It is possible to by-pass visibility using the modifier friend:
The concepts of friends is discussed more thoroughly here.