Comma Operator
The comma operator has a lower priority than assignment (it has a lower priority than any operator in this regard), so if you remove the brackets, the assignment is executed first, and the result of the second expression is discarded. So that...
int a = 10, b = 20; int x = (a,b);
Note that the third line will throw an error because it is interpreted as a repeated declaration of b
, i.e.:
int y = a; int b;
At first I skipped this, but it makes sense. This is no different from the initial declaration of a
and b
, in which case the comma is not an operator, it is a separator.
Ed S. source share