There is a way to do this. But it's a bit complicated. (well not really, rather far fetched)
here goes:
the callback function in the class should be declared static. This is because normal functions also have to know which class there in (this variable). But static functions do not. Then if you still want to be able to acces data in the calling class, you have to give an extra parameter: the this var of the class.
So you'll have something like this:
Code:
void callEnum(void (*fnc)(void *, int), void * user)
{
for (int i=0; i<10; i++)
{
(*fnc)(user, i);
}
}
class callBack
{
static void fnc(void *, int);
void fncThis(int);
void enum();
};
void callBack::fnc(void * pntr, int val)
{
((callBack *)pntr)->fncThis(val);
}
void callBack::fncThis(int val)
{
printf("%i\n", val);
}
void callBack::enumFnc()
{
callEnum(fnc, this);
}
call callBack.enumFnc() to print 0 to 9.
HtH.
Joren