The only error in your code is that you forgot the semicolon at the end of the second line, but I assume that was a typographical error in composing your question, rather than the actual thrust of your question.
I see no reason why the code you've shown should produce a compilation error. It compiles just fine for me, and the value of a
is, in fact, 3.
See for yourself: the following code returns 3:
int main()
{
int a=1, b= 2, c=3;
a = (b,c);
return a;
}
The trick is your use of the comma operator, which evaluates its first operand and then discards the result, and then evaluates the second operand and returns its value.
However, as Charles Bailey notes, you have to wrap the code shown in the question inside of a function, otherwise you will get compilation errors in any compiler. C++ doesn't allow assignment statements outside of functions.