Visibility

We now apply access specifiers to the members of our classes. Access specifiers public and private determine the visibility or accessibility of an object’s attributes and operations to other objects. Before we can begin implementing our design, we must consider which attributes and operations of our classes should be public and which should be private.

Previously, we observed that data members normally should be private and that member functions invoked by clients of a given class should be public. Member functions that are called only by other member functions of the class as “utility functions,” however, normally should be private. The UML employs visibility markers for modeling the visibility of attributes and operations. Public ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.