Chapter 11. Study Guide

Review

There is a strong connection between operators and functions: both instruct the computer to perform a sequence of one or more actions. Generally, compilers recognize and process operators directly, generating the machine instructions to implement the actions. Alternatively, programmers write functions consisting of statements. The functions are either included in a language's API or are part of a specific program. C++ allows programmers to overload operators by using the operator to name a new function associated with a new class. Although programmers implement overloaded operators as functions, the operators allow an operator-and-operand syntax for calling them. Overloaded operators are controversial and disliked by some (e.g., Java's designers only overload two operators and disallow programmers to overload more).

This chapter also introduces the friend keyword to implement friend functions. Any function, not just an operator, can be a friend of a class, but C++ can only implement some significant operators as friends, so this is a natural place to introduce them. friend functions are not members of the friending class, but the class nevertheless permits them access to its private features.

Overloaded Operator Concepts

Know