Miscellaneous > Programming & Networking

Pointers To Member Functions

(1/1)

anphanax:
These Are Both Members Of the wlWindow Class:

 
quote:
// Declaration of member function.
LRESULT CALLBACK fProc(unsigned int);

// Failed attempt to define a member of
// another class with a pointer to
// public function.
xClass.xfProc   = &wlWindow::fProc;

--- End quote ---


Here's my error    
"Cannot convert long (pascal wlWindow::*)(unsigned int) to long(pascal *)(unsigned int)"

After reading a ton of stuff online, talking to people in chatrooms, and referring to c++ documentation, I still don't know how to fix this (or how to cast it properly). If anyone could help, it would be greatly appreciated.

Edit: The people in the chatrooms were basically useless (didn't know c++ period yet they were in a programming chatroom), and the guides online never mentioned anything like this.

[ February 17, 2004: Message edited by: anphanax ]

flap:
Can you post some more code? What's xClass? What type is xfProc?

solo:
The class type is part of the type of the function pointer. This is severely annoying but you must declare the pointer with the class type too. For instance:


--- Code: ---
--- End code ---


At least I THINK thats the syntax. That very much limits what you can do but in order for the function to access the other data in the class it's necessary. That said it may not be necessary if someFunc() was declared static. Im not sure. Ill get back to you.

Navigation

[0] Message Index

Go to full version