Scope resolution in cpp
Scope Resolution Operator
This operator is used to access the Global variable but also has a local variable with a same variable name.
Syntax:-
::Variable_name; |
{
State_1;
State_2;
:
:
}
↣It used to define number of functions outside of the class.
Ex:-
#include<iostream.h>
int a=30;
int main()
{
int a=20;
cout<<"::a="<<::a<<"\n";
cout<<"a="<<a;
return 0;
}
Out put:-
::a=30
a=20
Comments