They don't do the same thing anyway. The only situation that I can think of that they do same thing is when the value of the variable is not used. Like "++i;" or "i++;". In those cases the compiler will optimize, because it is too simple not to do so. You simply don't care about the "pre" vs "pro". You just have an increment.
For custom type (classes) you can have something like this
Code:
myClass& operator++() //pre-increment
{
this->value += 1;
return *this;
}
myClass operator++(int) //post-increment
{
myClass temp(*this);
this->value += 1;
return tmp;
}
So the post increment will have to make a copy. The compiler will probably not optimize in this case.
So post-increment is guaranteed to be equal or faster.
If you know that they are the same (because they are fundamental types for example) then it is a matter of style. But that is an if. If you see a code that has
Code:
for (i=0; i < count; i++) ...
then "i" might not be an int. It can be a custom class. In which case the "i++" would probably be wrong.
if you see
Code:
for (int i=0; i < count; i++) ...
then you know "i" is an int and no problem.
If you don't overload ++ or -- I don't think you will have to worry which one to use...