The difference between x ++ and ++ x's

I believe this issue will be met in many programming languages, which can be quite senseless to force people started going to the programming for.

Teacher's official statement is: operator to be in front of their operation, then another operator; operator later, perform other operations before further operation itself.

Anyway, I memorized this passage is, but only to find a calculation or a look ignorant force.

I have these two differences are so understandable: I x, ++ x, x ++ are seen as three different variables, x = ++ x; x ++ = x -1. Anyway, no matter what form should that x is incremented by one, and does not increase the variable x ++ 1.

Below is an example:

x=1

x++  +  ++x = 

From left to right, x ++, this case x = 2, x ++ = 1;

Then further look ++ x, the previous x = 2, this time increment x 1, x = 3 = ++ x

So the final answer is 1 + 3 = 4

 

Guess you like

Origin www.cnblogs.com/angle-yan/p/11222491.html