I can not grasp the concept as to how these statements produce different values. As far as I know x+=1, means x = x + 1. I also know that x++ should be equivalent to x + 1.
I've also searched this topic and found posts which ask the same question, those posts are answered usually by stating the statements/expressions are the same, but the different result was due to another code mistake. With the example I will provide I don't see how there is a code mistake so please explain, thank you.
int x = 0;
x++;
x should be 1 at this point because x++ adds 1 to x.
So why is it that if I assign x to 0, and then proceed to code "cout << x++;" I get a value of 0 on the screen?!. How does x++ become 0 if x++ is equal to x+1 and if x is 0 then 1+0=1? I've been told its due to ++ being put after x, but why does that matter if dealing with addition 1 + 0 is the same as 0 + 1?