Thursday, October 16, 2014

use of scope resolution operator in c++



Prog 6: write a program for the use of scope resolution operator

#include<iostream.h>
#include <conio.h>
int x=10;
void main()
{
int x=20;
{
int A=x;
int x=30;
cout<<"\n in the inner block x is :"<
cout<<"A ="<
cout<<"\n from the scope resolution operator"<<::x;
}
cout<<"\n in the outer block x is :"<
cout<<"\n from the scope resolution operator"<<::x;
getch();
}

Output:

in the inner block x is :30
A =20
from the scope resolution operator10 in the outer block x is :20
from the scope resolution operator10

No comments: