Hiding the implementation (cont'd)

In Listing 3, the private data members and functions can be accessed only by other member functions of the class.

They cannot be accessed by program statements outside the class.

Thus, they are hidden from the using program.

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