October 1997
Intermediate to advanced
800 pages
20h 48m
English
The C++ compiler parses expressions into operands and operators, as shown in Table 6.9.
With the exception of the ternary conditional operator (?:), all C++ operators work with either one operand (unary) or two operands (binary).
| Expression Format | Operator Type | Examples |
|---|---|---|
| left_operand operator right_operand | Binary | a + b, a > b |
| left_operand operator | Unary (Postfix) | a++, a--, a-> |
| operator right_operand | Unary (Prefix) | ++a, --a, *a |
| operand1 ? operand2 : operand3 | Ternary | a > b ? a : b |
Table 6.10 lists the unary operators that you may overload.
| Operator | Examples | Operator | Examples |
|---|---|---|---|
| + | +a | ~ | ~a |
| - | -a | ! | !a |
| * | *a | ++ | a++, ++a |
| & | &a | -- | a--, --a |
| -> | a-> |