scope operator ::

1
2
3
4
5
6
7
void CAccess_Guard::ExecuteWindow()
{
   if(::GetTopWindowID() == ....)
   //is the scope operator here ::GetTopWindow is equivalent to
   //        CAccess_Guard::GetTopWindow =? ::GetTopWindow?
   //thanks..
}    
::GetTopWindow means call GetTopWindow visible from the global scope. In your case, that is NOT CAccess_Guard::GetTopWindow, bit the global one.
I see. So what is the reason why you want a function to be "visible" in a global scope? So that you can access it anywhere in your file?
Globally visible functions are functions defined in the global namespace. Most of the functions that appear in system header files and all C functions appear in the global namespace.

However, you can define functions of the same name (overload) in a namespace or a class. If you're in a class and your class has a function with the same name as a global one, you have to use :: to make it clear the to compiler that mean to invoke the global one, otherwise you'll get the one closest (in scope) to you.

In your example, if your class didn't have a method called GetTopWindowID, you wouldn't need ::
Thank you very much kbw for the help. :)

Topic archived. No new replies allowed.