The difference between C and C++ regarding the ++ operator
I have been fooling around with some code and saw something that I don't understand the "why" of. int i = 6; int j; int *ptr = &i; int *ptr1 = &j j = i++; //now j == 6 and i == 7. Straightforward. What if you put the operator on the left side of the equals sign? ++ptr = ptr1; is equivalent to (ptr = ptr + 1) = ptr1; whereas ptr++ = ptr1; is equivalent to ptr = ptr + 1 = ptr1; The postfix runs a compilation error and I get it. You've got a constant "ptr + 1" on the left side of an assignment operator. Fair enough. The prefix one compiles and WORKS in C++. Yes, I understand it's messy and you're