SFML community forums
Help => System => Topic started by: Howitzer21 on February 15, 2012, 02:00:41 am
-
How do you use threads with class member functions? If I pass a function pointer to a global function to a new Thread object, that works fine. If I try to pass a function pointer to a member function inside of a class, that doesn't work out too well. What's the syntax for it? Thanks!
-
SFML 1.6 or 2?
-
1.6
-
Ok. So just read the tutorial please ;)
-
I DID read the tutorial. I practiced it and everything. There was stuff in there for using them with function pointers to globally-defined functions, as well as inheriting a class from them. But as for not using inheritance and just passing a function pointer to a class function, there's really no reference there. I've tried it myself and haven't been able to get it to wrok.
-
Well, I did manage to get it working with static functions, but what if I want to use a function specifically associated with that object without having the class inherit from Thread? Is there a way to do this?
-
But as for not using inheritance and just passing a function pointer to a class function, there's really no reference there.
Because there is no possibility. Function pointers and member function pointers are not compatible to each other.
If I remember the old API correctly, you can use the void* to call indirectly a class member function. But you'd probably better use SFML 2.
-
Thanks, Nexus!