Access functions can read or display data. Another common use for access functions is to test the truth or falsity of conditions—such functions are often called predicate functions. An example of a predicate function would be an isEmpty
function for any container class—a class capable of holding many objects, like a vector
. A program might test isEmpty
before attempting to read another item from the container object. An isFull
predicate function might test a container-class object to determine whether it has no additional room. Useful predicate functions for our Time
class might be isAM
and isPM
.
3.149.242.175