Sign in to follow this  

How to correctly retrieve pointer to member-function?

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

This topic is 3669 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this