EXPLORATION 13

image

Compound Statements

You have already used compound statements (that is, lists of statements enclosed in curly braces) in many programs. Now it’s time to learn some of the special rules and uses for compound statements, which are also known as blocks.

Statements

C++ has some hairy, scary syntax rules. By comparison though, the syntax for statements is downright simplistic. The C++ grammar defines most statements in terms of other statements. For example, the rule for while statements is

while (condition)statement

In this example, bold elements are required, such as the while keyword. Italic elements stand for other syntax rules. ...

Get Exploring C++ 11, Second Edition now with the O’Reilly learning platform.

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