I've used SO for a while as a reference, but never asked a question before. I'm currently in a college C++ class and also reading Programming: Principles and Practice by Bjarne Stroutstrup just for my own benifit, as I saw an answer to a question here that really recommended it.
We're covering operators at the moment in my class, and I just can't seem to wrap my head around how the comma operator works in a statement. One example is a sample question for the online portion of the class that I keep getting wrong, even if I write a C program and use GDB to get the result. The question is:
Assuming x==16 before the following expression, what is the value of the following expression (not necessarily the value of x)?
x++, ++x, x+=x
I'm not interested in the correct answer so much as how to get the correct answer. I've read through a couple answers to similar questions, such as this one here, but it seems like I'm missing how this applies when there is actually no assigment operator. Is this the same as saying
int y = (x++, ++x, x+=x);
or
int y = x++, ++x, x+=x;
or neither? Could someone please explain how the comma operator works, specifically in relation to a statement without an assignment?