by Hexstream · 17y ago · 0 comments
Not that pre- and post-increment are ever that intuitive or transparent...
In C++, it's suggested to do ++i because it will sometimes result in fewer calculations if i is an object with overloaded increment operators.
Mainly I was taught that situations that require i++ are less common, more subtle, and easier to get wrong, so programmers should make them stand out by using ++i everywhere else.
as: FOO; while (BAR) { BODY; BAZ; }
Hence, ++i and i++ mean the same in this context. The difference, as mentioned already, is that i++ creates a copy of i.