0
Why is the output same whether i write i++ or ++i
Istarric right angle triangle https://code.sololearn.com/cvWzsPxNRAQ1/?ref=app
5 Answers
+ 4
BeegCat
I was informed that it matters insignificantly when it comes to built-in types (here loop counter type - `int`).
When working with objects, where the class implements overload for increment operator (post and/or pre), then it needs to be considered. Because it helps reduce possibility of creating a copy of the object to return by the overload đ
+ 1
y = ++x :
x = x + 1
y = x
y = x++ :
y = x
x = x + 1
When only used to increment x. x++ is used most of the time.
0
Inside for...loop definition they behave the same, no difference at all ...
0
Ok thanks đ