4.1 Expression Statements

   

An expression statement computes an expression, such as a function call or assignment. The expression result is discarded, so the expression is typically evaluated for its side effects. (See Chapter 3 for details about expressions.) The statement syntax is simply an optional expression followed by a semicolon:

   expr   ; 

or:

 ; 

A statement with no expression is called a null statement . Null statements are most often used for loops when no code is needed in the loop body.

Here are several examples of expression statements:

 42;          // Valid but pointless cout << 42;  // More typical x = y * z;   // Remember that assignment is an expression ;            // Null statement 
   


C++ in a Nutshell
C++ in a Nutshell
ISBN: 059600298X
EAN: 2147483647
Year: 2005
Pages: 270
Authors: Ray Lischner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net