Depends on the type of result1, result2 , etc.
expressionC ? expression1 : expression2 expressionC ? expression1 : expression2 not valid for all types expression1 and expression2 . They must be converted to a general type, roughly speaking (exact rules and exceptions can be read in the standard). Now, if result are strings, you do it like this:
std::cout << ( condition1 ? result1 : "Error" ) ^^^ << ( condition2 ? result2 : "Error") ^^^ << etc.
But if the results are integers, for example, you cannot do this.
NTN
Armen Tsirunyan
source share