Program to illustrate the Scope Resolution Operator


     # include <iostream.h>
    int m =10;                    // Global Declaration. 'm' is global variable.
    int main( )
     {        int m = 20          //'m' declared, local to main
               {
                        int k = m ;
                        int m = 30 ;  //'m' declared again local to main

                     cout << " We are in inner Block \n ";
                     cout << " k =  " <<  k << " \n";
                     cout << " m =  " <<  m << " \n";
                     cout << " :: m = " << :: m<< " \n";
                 }
                 cout << " We are in Outer Block \n ";
                 cout << " m =  " <<  m << " \n";
                 cout << " :: m = " << :: m<< " \n";

               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|