Hiding the implementation

An encapsulated design hides its implementation from the class user.

It reveals only its interface.

Listing 3 is an example of an encapsulated class:

Listing 3. Encapsulation.
class Date{
  //--- Implementation is private by default
  int month, day, year;//private data members
  ...//other private data members or functions
  public://the class interface is made public
  Date(int mo,int da,int yr);//public constructor
  Date operator+(int n);//public overloaded operator
  ...//other public interface functions
};// note the required semicolon