Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question