scope resolution operator without a scope

It means global scope. You might need to use this operator when you have conflicting functions or variables in the same scope and you need to use a global one. You might have something like:

void bar();    // this is a global function

class foo {
    void some_func() { ::bar(); }    // this function is calling the global bar() and not the class version
    void bar();                      // this is a class member
};

If you need to call the global bar() function from within a class member function, you should use ::bar() to get to the global version of the function.

Leave a Comment