Statements
C++ statements are the program elements that control how and in what order objects are manipulated. This chapter includes:
-
Overview
-
Labeled Statements
-
Categories of Statements
-
Expression statements. These statements evaluate an expression for its side effects or for its return value.
-
Null statements. These statements can be provided where a statement is required by the C++ syntax but where no action is to be taken.
-
Compound statements. These statements are groups of statements enclosed in curly braces ({ }). They can be used wherever the grammar calls for a single statement.
-
Selection statements. These statements perform a test; they then execute one section of code if the test evaluates to true (nonzero). They may execute another section of code if the test evaluates to false.
-
Iteration statements. These statements provide for repeated execution of a block of code until a specified termination criterion is met.
-
Jump statements. These statements either transfer control immediately to another location in the function or return control from the function.
-
Declaration statements. Declarations introduce a name into a program. (Chapter 6, Declarations, provides more detailed information about declarations.)
-
Exception handling statements, which include C++ exception handling (try, throw, catch) and structured exception handling (__try/__except, __try/__finally). The try-except statement provides a method to gain control of a program when events that normally terminate execution occur. The try-finally and leave statements provide a method to guarantee execution of cleanup code when execution of a block of code is interrupted.