Jump to content
  • Advertisement
Sign in to follow this  
jlewicki

::MessageBox

This topic is 4539 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

if(!InitWindowsApp(hInstance, nShowCmd)) 
	{
		::MessageBox(0, "Init - Failed", "Error", MB_OK);
		return 0;
	}
what is the purpose of the "::" operators at the beginning of the messagebox function?

Share this post


Link to post
Share on other sites
Advertisement
The :: tells the compiler to use the MessageBox function at the global scope - i.e. not within any classes or namespaces. This is useful if you are, for example, using a class that contains a function called MessageBox but you want to call the Win32 function by the same name.

Share this post


Link to post
Share on other sites
"::" without left operand make it use global namespace's MessageBox function.
The left operand indicate the object(class), the right operand indicate member function/variable.

Example:

class example {
public:
static int Hello;
static MessageBox(){};
};

void main {
example::Hello = 15; // This will set "example" class's static variable "Hello" to 15
example::MessageBox(); // This will call "example" class's static function "MessageBox"
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!