Just up the Block

Our most recent programming example has contributed another item to our arsenal of programming weapons: namely, the ability to group several statements into one logical section of a program. That's the function of the curly braces { and }. The first one of these starts such a section, called a block and the second one ends the block. Because the two statements after the while are part of the same block, they are treated as a unit; both are executed if the condition in the while is true, and neither is executed if it is false. A block can be used anywhere that a statement can be used, and is treated in exactly the same way as if it were one statement.[34]

[34] If you look at someone else's C++ program, you're likely to see a different ...

Get Learning to Program in C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.