Skip to main content
gamedev.net
🔒 Locked

Function pointer issue

Started by jvsstudios 2 replies 650+ views
Original Post
jvsstudios
jvsstudios
OK. I have a dynamically created class that I want to get a pointer to a member function( used to assign that function as a callback in a signal/slot scheme ). In VS 2005 I get a 'illegal operation on bound member function expression' error. MS says to take the address of the function as ClassName::MemberName. That only further complicates things as it doesn't get the actual address of the function. So my question is how do I accomplish this?
Evil Steve
Evil Steve
typedef int (ClassName::*LPFunction)(int nFoo);LPFunction pfn = MyFunction; // MyFunction is a member function// Call functionreturn (this->*pfn)(42);
jvsstudios
jvsstudios
Thanks for the replies.

Rip-Off: The web link was very helpful in understanding member function pointers. KUDOS!

Evil Steve: Thanks a bunch for that syntax as that pointed me in the right direction.

The problem I found was with MS implementation of mfp's. I added #pragma pointers_to_members(full_generality) to the code along with a compiler switch of /vmg in order to get it to work. In my search for answers, some of them came from this link.

Again thanks, I believe I am fixed for now.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.