2

I came across a piece of code which looks like this:

::GetSystemDirectory(buffer, MAX_PATH);

I've never seen a function call preceded by an empty ::. I've always seen them being used with namespaces.

Can someone please explain me what does an empty :: mean ?

brainydexter
  • 18,916
  • 27
  • 74
  • 112

1 Answers1

8

It's the scope resolution operator. With nothing in front of it, it indicates global scope.

So for instance, suppose you have a class that defines its own GetSystemDirectory method. Within the code of a method of that class, to call the global one, you'd need the :: in front of it, otherwise by default you'd get the one specific to the class. (And similarly for namespaces.)

T.J. Crowder
  • 959,406
  • 173
  • 1,780
  • 1,769