O'Reilly logo

Exploring C++ 11, Second Edition by Ray Lischner

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

EXPLORATION 46

image

More Operators

C++ has lots of operators. Lots and lots. So far, I’ve introduced the basic operators that you require for most programs: arithmetic, comparison, assignment, subscript, and function call. Now it’s time to introduce some more: additional assignment operators, the conditional operator (which is like having an if statement in the middle of an expression), and the comma operator (most often used in for loops).

Conditional Operator

The conditional operator is a unique entry in the C++ operator bestiary, being a ternary operator, that is, an operator that takes three operands.

condition ? true-part : false-part

The condition ...

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