Miscellaneous
The ternary operator ? :
-a //A unary operator has one operand.
&a
++a
a++
*p
a + b //A binary operator has two operands.
a - b
a * b
a / b
a % b
a ? b : c //A ternary operator has three operands.
- The ternary operator
? :
allows
price2
to be
const.
ternary1.C,
ternary1.txt
- Another example of the ternary operator
? :
Our first example of a
map
was the
Ikea map.
Last week’s example of a
map
was
vacation.C.
ternary2.C,
ternary2.txt
- Another example of the ternary operator
? :
Need parentheses because
?:
has comparatively low
precedence
(level 15, far below the
<<
at level 7).
ternary3.C,
ternary3.txt