Expression Statements. McGraw-Hill The Complete Reference Fourth Edition
বিজ্ঞাপন
বিজ্ঞাপন
88
C + + : T h e C o m p l e t e R e f e r e n c e
Expression Statements
Chapter 2 covered expressions thoroughly. However, a few special points are mentioned here. Remember, an expression statement is simply a valid expression followed by a semicolon, as in func(); /* a function call */ a = b+c; /* an assignment statement */ b+f(); /* a valid, but strange statement */
; /* an empty statement */
The first expression statement executes a function call. The second is an assignment.
The third expression, though strange, is still evaluated by the C++ compiler and the function f( ) is called. The final example shows that a statement can be empty
(sometimes called a null statement).
Block Statements
Block statements are simply groups of related statements that are treated as a unit. The statements that make up a block are logically bound together. Block statements are also called compound statements. A block is begun with a { and terminated by its matching }.
Programmers use block statements most commonly to create a multistatement target for some other statement, such as if. However, you may place a block statement anywhere you would put any other statement. For example, this is perfectly valid
(although unusual) C/C++ code:
#include <stdio.h> int main(void)
{ int i;
{ /* a block statement */ i = 120; printf("%d", i);
}
} return 0;
Chapter 4
Arrays and
Null-Terminated Strings
89
Copyright © 2003 by The McGraw-Hill Companies. Click here for terms of use.
ডাউনলোড
বিজ্ঞাপন