Jump to content
  • Advertisement
Sign in to follow this  
andrew1b

Method and function name conflict

This topic is 2953 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

I'm in a bit of a trouble here. I have the following class:


#include <windows.h>

class Input
{
// ... not relevant code...
short GetKeyState(const KEY &key)
{
return m_keyState[key];
}

void Update()
{
for (int t=0; t<m_nKeys; t++)
{
// calls the Win32 GetKeyState function to retrieve key state
m_keyState[t] = GetKeyState(m_win32Key[t]);
}
}
};




I can't compile it because C++ thinks that I'm calling Input::GetKeyState instead of Win32's global function.
Is there any way I can solve it without changing my method name?

Share this post


Link to post
Share on other sites
Advertisement
That worked. Thanks. I thought that :: would mean that I'm trying to access the closest function. I must have misunderstood it.

Share this post


Link to post
Share on other sites
Be careful when overloading the Win32 functions. Anything dealing with strings will be re-#defined to a specific Unicode or ANSI function, depending on what you're compiling as. So, e.g., CreateWindow would be come CreateWindowA or CreateWindowW.

Anyway... In practice this usually causes trouble when attempting to overload such a function name in a header, where one module using the function includes <windows.h> and another doesn't, or where <windows.h> is included after your own header.

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!