Access functions can read or display data, not modify it. Another common use of access functions is to test the truth or falsity of conditions—such functions are often called predicate functions. An example would be an empty
function for any container class—a class capable of holding many objects, such as an array
or a vector
. A program might test empty
before attempting to read another item from the container object.2
A utility function (also called a helper function) is a private
member function that supports the operation of a class’s other member functions. Utility functions are declared private
because they’re not intended for use by the class’s clients. A popular use of a utility function would be to place in a function some common code that would otherwise be duplicated in several other member functions.