Increment difference before and after the auto-incremented

See Methods increment after increment and the difference before several online and found too much trouble to explain, is not easy to understand and remember, here to do some simple explanation, but easy to understand and remember (at least I personally think so ^ _ ^)

Same point:

  Whether ++ i or i ++, are in fact equivalent to i = i + 1.

difference:

  The return value is not the same. ++ i returns the value of i = i + 1 of the left side of the equation, i.e., an added value. i ++ returns the value of i = i + 1 on the right equation, i.e., a value before the increase.

to sum up:

  ++ i takes values ​​left, i ++ take rvalue, left and right corresponds to the i = i + 1 i.

Guess you like

Origin www.cnblogs.com/chengzi-he/p/10969048.html