Conditional operator differences between C and C++
I read somewhere that the ?: operator in C is slightly different in C++, that there's some source code that works differently in both languages. Unfortunately, I can't find the text anywhere. Does anyone know what this difference is? The conditional operator in C++ can return an lvalue, whereas C does not allow for similar functionality. Hence, the following is legal in C++: (true ? a : b) = 1; To replicate this in C, you would have to resort to if/else, or deal with references directly: *(true ? &a : &b) = 1; Also in C++, ?: and = operators have equal precedence and group right-to-left , such