new

Started by
30 comments, last by _johan 21 years, 9 months ago
Prefix operator++ increments the value and returns it. Postfix operator++ increments the value and returns the previous value. The latter requires creation of a temporary, as there are clearly two different values involved. In the case of built-ins such as int, the compiler can most likely optimise out the temporary. If it is a User-Defined Type, the creation of a temporary might be undesirable. In a for loop, there is no difference in side-effects between the two, so it makes sense to go for the cheapest option.
Advertisement
I''ve learnt something new (to me) anyway, cheers .

,Jay

This topic is closed to new replies.

Advertisement