What’s the purpose of a leading “::” in a C++ method call

To refer to the root namespace. This is often useful if your class or you namespace uses a name which also exists in the root, but at some point you wish to refer to the root version.

For example, if I have overloaded new in my class, but wish at some point to refer to the default (root) new, then I would use ::new to refer to root new.

Leave a Comment