Is this true.. ++i better than i++
Postfix increment and decrement operators create a temporary object when used while prefix operators don’t.
It is therefore more efficient to use the prefix version where possible, particularly in for loop constructs as whatever is used will be called multiple times in that case, i.e.,
we should use:
for (int nType = 0; nType < MM_NUM_TYPES; ++nType)
{
…
}
Re: Is this true.. ++i better than i++
Quote:
Originally posted by zoltan_ie
Postfix increment and decrement operators create a temporary object when used while prefix operators don’t.
Yes, prefix operator are faster. If there is no need to use the original value, it is better to use prefix operator.