This might be dumb question, but can someone tell me what is the difference? I read somewhere that when your evaluating something if you use ++i, "i" is increased then function is evaluated, but if you use i++, function is evaluated then "i" is increased.
But when I ran this:
and this:Code:int n = 0; for (int i = 0; i < 10; ++i) { n++; std::cout << n << ". " << i << std::endl; }
Code:int n = 0; for (int i = 0; i < 10; i++) { ++n; std::cout << n << ". " << i << std::endl; }
in both cases I get:
So what is the difference?Code:1. 0 2. 1 3. 2 4. 3 5. 4 6. 5 7. 6 8. 7 9. 8 10. 9
Don't know if that makes any difference but this is run on Visual Studio 2005



LinkBack URL
About LinkBacks



