+ 1

what is the difference between ++x and x++

14th Jun 2016, 3:55 PM
anirudh
anirudh - avatar
3 Answers
+ 2
++x sums one and returns x, x++ returns x and THEN sums one
14th Jun 2016, 6:34 PM
Guillermo FernĂĄndez
Guillermo FernĂĄndez - avatar
+ 1
++x means x+1=x,, increment is performed first then value is assigned x++ means x=x+1,, value is assigned first then increment is performed..
15th Jun 2016, 11:55 AM
Mahrukh Ahmed
Mahrukh Ahmed - avatar
+ 1
With objects you have to notice that post increment creates (often) an unnecessary copy of the object. This might affect the performance. Smart compilers however optimize this.
16th Jun 2016, 8:00 PM
VPA
VPA - avatar