``Data Hiding'' zur Unterstützung modularen Programmierens:
class X { int a; // private by default
}; // don't forget the ";"
struct X { int a; // public by default
};
Die Standard-Zugriffsbeschränkung wird geändert durch Zugriffsspezifikationen:
Verletzung der Zugriffserlaubnis meldet der Compiler:
class date
{ int day, month, year;
};
...
date today;
cout << today.day;
g++:
member day is a private member of class date.
CC:
cannot access date::day: private member.
Verbot des Zugriffs auf date, month, year erlaubt Umstellung der Implementierung:
class date
{ long julian;
};
ohne die Anwendung zu tangieren.