recently I saw the following compiler error error: ‘::main’ must return ‘int’.
That reminded my that long ago I wondered why sometimes you can find ::something. What does :: without a preceeding namespace mean?
I also used it a while ago, but I don't know why. And I don't do that anymore. (There is a post I made here where i write ::toupper, but I have no idea why I did it, and why I should do it :D)
It explicitly refers to the global namespace; that is, identifiers that are not in any namespace. Otherwise, an identifier refers to the "most local" of the possibilities.
1 2 3 4 5 6
int i = 0;
int main() {
int i = 1; // this i is said to "shadow" the outer i
std::cout << " i = " << i << "\n"; // 1
std::cout << "::i = " << ::i << std::endl; // 0
}