What is a scope resolution operator?

Scope resolution operator is used to uncover the hidden variables. It also allows access to global version of variables. 

Program Code:
#include<iostream>
using namespace std;
// global variable x of the program
int x=10; 

int main( ) 
// local variable x of the program
int x=20; 
cout<<"This is the value of local variable x = "<<x;
cout<<endl; 
// to access global variable in main program use scope resolution operator (::) in front of global variable
cout<<"This the value of global variable x = "<<::x; 
cout<<endl;
return 0;

The program output is tested on www.jdoodle.com
Output:
This is the value of local variable x = 20
This the value of global variable x = 10


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: