Definition:
Use the double colon operator (::) to qualify a C++ member function, a top level function, or a variable with global scope with: An overloaded name (same name used with different argument types) An ambiguous name (same name used in different classes)
class A
{
static int i; // scope of A
};
namespace B
{
int j;
}
int A::i = 4; // scope operator refers to the integer i declared in the class A
int B::j = 2; // scope operator refers to the integer j declared in the namespace B
The :: (scope resolution) operator is used to qualify hidden names so that you can still use them. You can use the unary scope operator if a namespace scope or global scope name is hidden by an explicit declaration of the same name in a block or class. For example:
int count = 0;
int main(void) {
int count = 0;
::count = 1; // set global count to 1
count = 2; // set local count to 2
return 0;
}