Scope resolution operator of c++ example
Scope resolution operator example
#include<iostream>
using namespace std;
int m=10; //global m
int main()
{
int m=20; //m redeclared local to main
{
int k=m; //m declared again
int m=30; // local to inner block
cout<<"we are in the inner block\n";
cout<<"k="<< k<<"\n";
cout<<"m="<<m<<"\n";
cout<<"::m="<<::m<<"\n";
cout<<"::m="<<::m<<"\n";
cout<<"::m="<<::m<<"\n";
}
cout<<"\nwe are in outer block \n";
cout<<"m="<<m<<"\n";
cout<<"::m="<<::m<<"\n";
cout<<"::m="<<::m<<"\n";
return 0;
}
Comments
Post a Comment