I prefer to use ++i for most cases. As it does one thing instead of two.
My loops always have a ++i incrementor. Even though it does not make much difference. Usually the needless stack operation you get with i++ is optimized away. So there is no performance impact.
This is definitely a good habit in C++, where you can overload ++i and i++.
If you are using a custom type, i++ is required to return a temporary object representing the old state of the object, whereas ++i is allowed to 'increment' the i object and return the same object.
Compilers might be able to figure this out, but it's better to not make them do so.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I prefer to use ++i for most cases. As it does one thing instead of two.
My loops always have a ++i incrementor. Even though it does not make much difference. Usually the needless stack operation you get with i++ is optimized away. So there is no performance impact.
This is definitely a good habit in C++, where you can overload ++i and i++.
If you are using a custom type, i++ is required to return a temporary object representing the old state of the object, whereas ++i is allowed to 'increment' the i object and return the same object.
Compilers might be able to figure this out, but it's better to not make them do so.