Jump to content
  • Advertisement
Sign in to follow this  
S T A L I N

How to correctly retrieve pointer to member-function?

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

Hello, guys! I have such question. I'm writing my own wrapper for WINAPI. So I faced a challenge. Please look through the code below: /================== window.h =================== // general main window class class wnd { HWND hWnd; WNDCLASSEX wc; .... public: wnd(HINSTANCE hInst, int nCmdShow, LPCSTR lpCapt, unsigned int uiLeft, unsigned int uiTop, unsigned int uiWidth, unsigned int uiHeight); // CONSTRUCTOR // WINDOW PROCEDURE LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); .... }; /======================== window.cpp ================================= // CONSTRUCTOR wnd::wnd(HINSTANCE hInst, int nCmdShow, LPCSTR lpCapt, unsigned int uiLeft, unsigned int uiTop, unsigned int uiWidth, unsigned int uiHeight) { // do some initialization .... // setting WNDCLASSEX wc; .... wc.lpfnWndProc = WndProc; // ERRRRRRRRRORRR !!!! .... ========================= End of Code ================================= How should I change class constructor code to fix this error ???????????

Share this post


Link to post
Share on other sites
Advertisement
If you look at the type of HWND you'll see that its type is of "pointer to function", not a "pointer to member function", which has entirely different syntax and requirements.

First of all a pointer to a class member has no meaning unless it has an instance to act on. So simply assigning the pointer to HWND won't work.

The technique for solving this problem is addressed here . You should probably read that entire FAQ section to get a better handle of how pointer to member functions work.

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!