I dont wanna try your code, but try this and see if you understand it better.
using namespace std;
int count = 0;
int MAX = 20;
for(int i = 0; i < MAX; i++)
cout << "i is [" << i << "] and count is [" << count << "] using a postfix increment op." << endl;
cout << "Clearing Count" << endl;
count = 0;
cout << "Count is now: " << count << endl;
for(int i = 0; i < MAX; ++i)
cout << " i is [" << i << "] and count is [" << count << "] using a prefix increment op." << endl;
Interesting read, I followed then link to lang.c.com or something along those lines and read up on some of the information, and that is stuff i have never heard before... I was always told to use increment op's or decrement ops for shorthand to modify the value of a counter...
shimsha -- it is undefined behavior to use post/pre increment on the same value within the same expression multiple times. So the output of your program is dependent upon the compiler and compiler settings.
@IngeniousHax -- not a lie. You just have to know and follow the rules. Be careful when dealing with side-effects. Using inc/dec for counters/iterators is ok, but don't go about trying to get all fancy and pack everything into one expression.
shimsha, the "teaching" of this sort of thing seems to be endemic to your country (along with Turbo C/C++, fflush(stdin), and gets()). I would LOVE to know, in this particular case, if the lesson to be learned here is NOT to do this, or if they are teaching you that it is perfectly normal and acceptable. I suspect the latter, and that seriously makes me angry.