O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6.6. Operator Functions

Class designers must make correct decisions when overloading operators for class objects. Otherwise, expressions may be ambiguous, generate undesired conversions, or produce compilation errors. This section covers general schemes for operator overloading and gives you guidelines for creating consistent class designs.

How does operator overloading work with objects? Expressions with unary or binary operands map to specialized function calls. Table 6.12 lists the formats.

A horizontal line in Table 6.12 separates two format groups. In the first group, # is any C++ operator except =, [], (), ->, and postfix ++ and -- (which appear in the second group). In both groups, the compiler translates expressions with C++ operators ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required