#include <iostream>
using namespace std;
Code:
int a = 12; // here it is a global variable
int main() {
int a = 13; // here it is a local variable
cout << ::a << endl;
cout << a << endl;
}
The above example shows you the scope resolution operator , but besides that there is one more use of this operator i.e to access the members that are been declared in class scope. I think the above given example is enough to explain you about the basic functionality of a scope resolution scope resolution operator is used the name of the member that follows the operator is looked up in the scope of the class with the name that appears before the operator.
Bookmarks