Using access labels and access regions
Labels may be introduced into a class (or structure) definition to control the access or visibility of class (or structure) members. By controlling the direct access of members from various scopes in our application, we can support encapsulation and information hiding. That is, we can insist that users of our classes use the functions that we select, with the protocols we select, to manipulate data and other member functions within the class in ways we, the programmers, find reasonable and acceptable. Furthermore, we can hide the implementation details of the class by advertising to the user only the desired public interface for a given class.
Data members or member functions, collectively referred to as members, can be individually labeled, or grouped together into access regions. The three labels or access regions that may be specified are as follows:
- private: Data members and member functions in this access region are only accessible...