Statements
A C++ program contains statements that alter the state of the storage managed by the program and determine the flow of program execution. There are several types of C++ statements, most of which are inherited from the C language. First, there is the simple statement, terminated with a semicolon, such as
x = y + z;
Next, there is the compound statement, or block, consisting of a sequence of statements enclosed in curly braces.
{ int temp = x; x = y; y = temp; }
The above example is a single compound statement that contains three simple statements. The variable temp is local to the block and is destroyed when the end of the block is reached.
In general, a compound statement can be placed wherever a simple statement can go. The reverse is not always true, however. In particular, the function definition
double area(double length, double width) { return length * width; }
cannot be replaced by
double area(double length, double width) return length * width;
The body of a function definition must always include a block.