My question is, what is the difference between these two keywords (if any) as they relate to classes?
My question is, what is the difference between these two keywords (if any) as they relate to classes?
protected: objects can be accesses only by methods of this and derived classes.
private: objects can only be accessed by method of this class.
use google and you will find lots of other explainations and examples, which all amount to the above.
Quote from C++ from the Ground Up by Herbert Schildt
When a base class is inherited by use of public, its public members become public members of the derived class, and its protected members become protected members of the derived class.
When a base class is inherited by use of protected, its public and protected members become protected members of the derived class.
When a base clas is inherited by use of private, its public and protected members become private members of the derived class.
In all cases, private members of a base class remain private to that base class, and are not inherited.
Within a class protected is the same as private. However, protected members can be inherited in derived classes.