© Ray Lischner 2020
R. LischnerExploring C++20https://doi.org/10.1007/978-1-4842-5961-0_49

49. More Operators

Ray Lischner1 
(1)
Ellicott City, MD, USA
 

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 ...

Get Exploring C++20: The Programmer's Introduction to C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.