Original Post
Hi folks!
Context:
I'm looking to reuse come win32 dialog code by inheriting each dialog from an abstract base class. Among base class code is the WNDCLASSEX structure, one of who's members is a function pointer to WndProc, which is declared pure virtual in the base class and implemented in the derived class.
Question:
How do I declare a pointer-to-derived-member-function in my base class? WndProc is a CALLBACK so I can justify bending the OO rules in this case (I'm calling a derived function from a base class!)
Here is some simplified code:
I've tried void* but no success. Is what I am trying to do even allowed? I think it should be because the address of the bound function foo() should be valid once I've called DerivedWin's ctor. Does the "type" of the member function pointer depend on the *signature* of foo(), or does some generic treatment exist?
Thanks folks, I alread know this is the best C++ forum on the net, I'm sure you won't let me down!
Context:
I'm looking to reuse come win32 dialog code by inheriting each dialog from an abstract base class. Among base class code is the WNDCLASSEX structure, one of who's members is a function pointer to WndProc, which is declared pure virtual in the base class and implemented in the derived class.
Question:
How do I declare a pointer-to-derived-member-function in my base class? WndProc is a CALLBACK so I can justify bending the OO rules in this case (I'm calling a derived function from a base class!)
Here is some simplified code:
class BaseWin{protected: Member_Function_Pointer_Type memFuncPtr; // what type here? virtual int foo() = 0;};class DerivedWin : public BaseWin{public: DerivedWin();protected: virtual int foo();}DerivedWin::DerivedWin(){ memFuncPtr = pointer_to_foo; // what to do here??? }int DerivedWin::foo(){ // implementation}I've tried void* but no success. Is what I am trying to do even allowed? I think it should be because the address of the bound function foo() should be valid once I've called DerivedWin's ctor. Does the "type" of the member function pointer depend on the *signature* of foo(), or does some generic treatment exist?
Thanks folks, I alread know this is the best C++ forum on the net, I'm sure you won't let me down!