Chapter 11. Study Guide

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 operators and can directly generate machine instructions to implement them. 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 create or overload operators by defining new functions associated with a new class. Although programmers implement overloaded operators as functions, the operators allow a special, convenient syntax for calling the functions. 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 can be a friend of a class, not just an operator, but we can only write some common and important 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