Program to illustrate the Nested & Parallel scopes


     # include <iostream.h>
    
    int x =11;                    // Global Declaration. 'x' is global variable.
    int main( )
     {       
    int x = 22;
    {         //begin scope of internal block
                 int x =33;
                 cout<<"In block inside main( ) : x =  "<<x << endl ;
    }       //end scope of internal block
    cout<<"In main( ) : x =  "<<x <<endl;
    cout<<"In main( ) :   ::x =  "<<::x <<endl;
                  return 0;
      }                               //end scope of main( )

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|