I am looking at someone else's C++ code (note I am not fluent in C++).
Within the class, there is this member function:
void ClassYaba::funcname()
{
...
::foo();
...
}
There is no member function within that class's namespace named foo
, but aside from that, what is the difference between ::foo()
and foo()
(no leading colons)?
When you call
foo();
C++ will search for something named foo
in the following order:
On the other hand, writing
::foo();
will make C++ look for something purely in the global namespace.
If there is nothing named foo
in your class, any of its base classes, or any namespaces foo
was declared inside of, then there's no difference between the two approaches.