A scope resolution operator (::), can be used to define the member functions of a class outside the class.
when we want to define the member function of the same class but the definition is at outside the class...at that time we have to use scope resolution operator...
1.scope resolution operator is used to define the member function outside the class. 2.it is also used to print the value of global variable and local variable . for example int a=10; void main() { int a=20; cout<<a; cout<<::a; } output 10 20
scope is nothing but the visibility of a variable or a member. The members declared in the class by default wil have the class scope. It gives us the information like to which particular class a member belongs to.
.scope resolution is represented as "::" .it is use for globel representation .we use it for declaring a member function out of class syntax:- void get::data(); wear void->returntype get->classname ::->scope resolution data->funtion name par->agruments
Scope resolution operator is used to access the global variable in a block where one of the local variable in that block have the same name as global variable.
int Num; class A { public: void Func() { int A =10; ::A =20;//Definition of Global Variable } };