It is called a region resolution operator.
Would you like to know what you could write instead of
:: ? Well, there is no alternative that always works. For your example, you can simply define those member functions in the body of your class that would be the built-in style of class definition:
class A{ int value; public: A() { value = 0; } void print() { cout << value << endl; } };
Thus, you obviously have no way to put the definition in another file, so they cannot be compiled separately.
At the same time, when :: used to solve the namespace , not the class , you can replace it with either re-opening this namespace or pulling it into scope with using namespace .
source share