What does "::DestroyWindow(hWnd)" mean?

J

Joseph

I read a piece of code, and the code looks like the following part.

CWnd is a MFC class

class CFrameGrabber : public CWnd {
....
};

BOOL CFrameGrabber::Create(int x, int y, CWnd *pParentWnd) {
.......
if( !capDriverConnect(hWnd, DEFAULT_CAPTURE_DRIVER)) {
::DestroyWindow(hWnd);
return FALSE;
}
.......
}

My question is: This is a correct code, and what does the preceding
"::" of the DestroyWindow(hWnd) really mean here? If I remove the
preceding "::" from the DestroyWindow(hWnd), the compiler will call the
inherited DestroyWindow() from CWnd class and generate an error.

I can not find any reference about the usage of "::" like this.
Previously, I've only seen something like A::test()....

Thanks
 
A

Alf P. Steinbach

* Joseph:
::DestroyWindow(hWnd);

My question is: This is a correct code, and what does the preceding
"::" of the DestroyWindow(hWnd) really mean here? If I remove the
preceding "::" from the DestroyWindow(hWnd), the compiler will call the
inherited DestroyWindow() from CWnd class and generate an error.

'::' refers to the global namespace. It ensures you're referring to a
freestanding function (or something) outside any namespace.

I can not find any reference about the usage of "::" like this.
Previously, I've only seen something like A::test()....

That's exactly the same, provided 'A' is a namespace name -- the name of
the global namespace is just nothing.
 
J

jeremiah johnson

no, the *most* annoying thing is someone that thinks they have the right
to tell others what to do when they're not asked to do so.
 
H

Howard

[re-arranged to be more readable :)]

jeremiah johnson said:
no, the *most* annoying thing is someone that thinks they have the right
to tell others what to do when they're not asked to do so.

Oh, c'mon...lighten up. It's just Alf's usual signature. It conveys a
useful message, and in a humorous way at that.

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top