Conditional Expression
Learn about conditional expressions, and how to use them in C++.
We'll cover the following...
There are expressions of a special kind, the conditional expressions; these are not statements, but they are sort of a contraction of the if-else
construct. This kind of expression can help to produce highly readable assignment statements fitting onto one line of the source code.
Syntax
This is the syntax:
Press + to interact
( condition ) ? expressionIfTrue : expressionIfFalse;
This is also depicted using the following illustration:
Press + to interact
First the condition is evaluated and: ...