May 2002
Beginner
320 pages
6h 18m
English
Almost every modern processor can increment and decrement in one machine instruction (and many can do it in a fraction of an instruction). Use of the ++ and -- operators enables C++ compilers to use special increment and decrement instructions in the code they generate from your C++ source. So by using
Index++;
rather than
Index = Index + 1;
you can help the compiler and speed up your program.
It is also possible that the compiler can optimize
Index+= 3;
to run faster than
Index = Index + 3;
for similar reasons.
Note that this will not help with overloaded operators, however, because they have user-defined implementations.
Read now
Unlock full access