Hiding the implementation of the class
•The C++ language provides three member access specifiers to describe the boundaries of which data members/member functions are available to whom: •public: means that what follows (data member or member function) is accessible to everyone, •private: means that what follows is accessible only from the member functions of the class itself •protected: means that what follows is accessible only from the class itself or from a class derived from it. •The default access specifier for a class if not explicitly stated is private.
http://www.alessandroogheri.com
The C++ member access specifiers permits to the class author to decide which data members and member functions are visible to whom.
This mechanism provides several advantages and improves overall the quality of design:
If the class user, who uses the class to create a more articulated design, can only see what is in the public section, then he/she doesn’t have to care of the implementation details that are not visible to him/her; this means that he/she can concentrate on how to use the class, and how this reacts to invocations of its member functions, instead of fiddling around with the internals of the data type;
On the other hand, for the class creator, this separation of interface and implementation is also beneficial, since he/she can change the internal representation of the storage of the data type, and even the algorithms embodied in the member functions, as long as he/she doesn’t change the interface of the class (the prototypes of the member functions); this ensures that such modifications will not break existing codes written by users of the class.