0
  double timestamp = ::a::b::c::NowInSeconds();

Already know the use of :: in varible selection, but what's the meaning of it when it is used at the beginning and followed with a function (with namespace specified) ?

user4581301
  • 33,082
  • 7
  • 33
  • 54
Andrew Wei
  • 13
  • 3

1 Answers1

3

The initial :: is used to explicitly specify that the name following it is located in the global/default namespace, and not in any other namespace that happens to be in scope. Here's an example of how that might be useful:

int a;

namespace b {
   int a;
};

using namespace b;

int main(int, char **)
{
   a = 5;   // error, reference to 'a' is ambiguous

   ::a = 5;   // ok
}
Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234