M
M
Max Suprunenko2015-12-21 23:40:27
C++ / C#
Max Suprunenko, 2015-12-21 23:40:27

Why do we need two colons without a class?

Why do we need two colons without a class? An example from Luna's book Introduction to DirectX 3D.

int DirectX1::EnterMsgLoop(bool(*ptr_display)(float timeDelta))
{
  MSG msg;
  ::ZeroMemory(&msg, sizeof(MSG));
  static float lastTime = (float)timeGetTime();
  while (msg.message != WM_QUIT) {
    if (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
    {
      ::TranslateMessage(&msg);
      ::DispatchMessage(&msg);
    }
    else
    {
      float currTime = (float)timeGetTime();
      float timeDelta = (currTime - lastTime) * 0.001f;
      ptr_display(timeDelta); // вызов функции                                     
                  // визуализации             
      lastTime = currTime;
    }
  }
  return msg.wParam;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MiiNiPaa, 2015-12-21
@msuprunenko

Indicates that the name is in the global scope.

I
isotoxin, 2015-12-31
@isotoxin

This is usually needed if there is a global function and a class member function with the same name, and you need to call the global one.

void foo() {
}

class bar
{
    bar()  {
        foo(); // будет вызван член класса foo
        ::foo(); // будет вызвана глобальная foo
    }
    void foo()  {
    }
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question