I have a condition
and three variables.
// Assume these variables are all initialized.
int *a;
int *b;
const int c;
const bool condition;
if (condition)
*a = c;
else
*b = c;
I want theif
block to be on one line through a ternary conditional operator.
(condition ? *a : *b) = c;
I don't see why that's not allowed as I'm not breaking the rule of ternary conditional operators. Both *a
and *b
return the same type.