I have seen people done this on the Web, but I got compiler error. Would
someone take a look what my problem is? All I am trying to do is to pass a
C++ function into the taskSpawn function within a class. I greatly
appreciate for any of your help.
//error messages from compiler.
..\testtask.cpp: In method `void A::init ()':
..\testtask.cpp:9: assuming & on `A::task'
..\testtask.cpp:9: converting from `void (A::*) (...)' to `int (*) (...)'
make: *** [testtask.o] Error 0x1
// the actual code
#include <taskLib.h>
class A
{
public:
void init()
{
taskSpawn("test", 100, 0, 10000, (FUNCPTR)A::task,
0,0,0,0,0,0,0,0,0,0);
}
void task(...) {}
};
Gordon
The task member function requires a 'this' pointer to be supplied to it:
Try something like:
class A
{
void init()
{
taskSpawn("test", 100, 0, 10000, (FUNCPTR)A::taskStart,
(int)this,0,0,0,0,0,0,0,0,0);
}
static void taskStart(A* obj)
{
obj->task();
}
void task(...) {}
};
--
Wade Oram
Reply address valid for at least 1 calendar month from date of posting.
Gordon
Wade Oram <news....@wtoram.co.uk> wrote in message news:<TZPvp6H8...@wtoram.co.uk>...