Expressions in the for Statement’s Header Are Optional

The three expressions in the for statement header are optional but the two semicolon separators are required. If the loopContinuationCondition is omitted, the condition is true, thus creating an infinite loop. One might omit the initialization expression if the control variable is initialized earlier in the program. One might omit the increment expression if the increment is calculated by statements in the body of the for or if no increment is needed.

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.