Your assumption of a conditional statement is incorrect. An expression type is any type that c.getA() and c.getB() , if they are of the same type, and if they denote lvalues, then the whole expression. (The exact rules are given in ยง5.16 of the C ++ standard.)
You can even do this:
(condition? a: b) = value;
conditionally set either a or b to value . Note that this is C ++ - specific; in C, the conditional operator does not denote an l-value.
source share