‘Private’ is discussed in the previous section, and ‘public’ means ‘anyone can access it’. The third option, ‘protected’, makes a member (either data member or member fn) accessible to subclasses. Thus members defined in the
‘private:’ section of class X are accessible only
to the member functions and friends of class X; members defined in the
‘public:’ section are accessible by everyone; ‘protected:’ members are
accessible by members fns and friends of class X, as well as member fns of
subclasses of X.