January 2011
Intermediate to advanced
1648 pages
70h 30m
English
Conceptually closely related to compound assignment with the + and - binary operators are the postfix and prefix increment and decrement operators. In essence, they abbreviate simple operators as “plus one” and “minus one” into succinct syntax, respectively as ++ and --. One common use can be found in the context of for loops, which are discussed in the Chapter 7, “Simple Control Flow.” Here is the typical pattern to create a loop that will execute the loop body 10 times:
for (int i = 0; i < 10; i++){ // Use integer value i if desired.}
A for loop consists of four parts: an initializer (here int i = 0), a condition (i < 10), an iterator (i++), and a loop body (the part in between curly braces). ...
Read now
Unlock full access