You are here

Other Uses of a Compound Statement

5 February, 2015 - 11:20

"A compound statement is a unit of code consisting of zero or more statements. It is also known as a block. The compound statement allows a group of statements to become one single entry. You used a compound statement in your first program when you formed the body of the function main. All C++ functions contain a compound statement known as the function body.

A compound statement consists of an opening brace, optional declarations, definitions, and statements, followed by a closing brace. Although all three are optional, one should be present.