andrew said:
does i++ have the same potential for side effects as its pre-fix
equivilent ++i? and if so, is it always dangerous to use them, as in a
for loop, or only in certain circumstances?
Define "potential for side effects". Both ++i and i++ will increment i,
if that is what you are asking (or in the case of class types, call the
corresponding version of operator++).
Also, specify what you mean by "dangerous to use them". It is quite
common for increment operators to be used in for loops:
for (unsigned i = 0; i < 10; ++i) { // Do something }
The only dangerous use I can think of is trying to use an increment
operator in an expression where the operand is also being used for
something else:
i = ++i + 1; // unspecified behavior
j = i + i++; // unspecified behavior
j = i++ + ++i; // unspecified behavior
Also, since it inevitably will come up:
http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.15