Skip to content

Latest commit

 

History

History
63 lines (54 loc) · 2.6 KB

overview-of-cpp-statements.md

File metadata and controls

63 lines (54 loc) · 2.6 KB
description title ms.date helpviewer_keywords ms.assetid
Learn more about: Overview of C++ Statements
Overview of C++ Statements
11/04/2016
statements [C++]
e56996b2-b846-4b99-ac94-ac72fffc5ec7

Overview of C++ Statements

C++ statements are executed sequentially, except when an expression statement, a selection statement, an iteration statement, or a jump statement specifically modifies that sequence.

Statements may be of the following types:

labeled-statement
expression-statement
compound-statement
selection-statement
iteration-statement
jump-statement
declaration-statement
try-throw-catch

In most cases, the C++ statement syntax is identical to that of ANSI C89. The primary difference between the two is that in C89, declarations are allowed only at the start of a block; C++ adds the declaration-statement, which effectively removes this restriction. This enables you to introduce variables at a point in the program where a precomputed initialization value can be calculated.

Declaring variables inside blocks also allows you to exercise precise control over the scope and lifetime of those variables.

The articles on statements describe the following C++ keywords:

:::row::: :::column span=""::: break
case
catch
continue
default
do :::column-end::: :::column span=""::: else
__except
__finally
for
goto :::column-end::: :::column span=""::: if
__if_exists
__if_not_exists
__leave
return :::column-end::: :::column span=""::: switch
throw
__try
try
while :::column-end::: :::row-end:::

See also

Statements