Original Post
Please excuse me if this sounds confusing, it makes sense in my head
.
The only way I can explain this is to show you some code:
I have a class:
myClass{
public:
void setFunction(void(*)(unsigned int));
}
Now, in another class I have:
otherClass {
public:
void functionToBeCalled(unsigned int);
void initFunction();
private:
myClass *blah;
}
initFunction()
{
blah->setFunction(functionToBeCalled);
}
This, of course does not work, I have tried many hack ways but to no avail.
Now, the only way I have been able to solve this is to create a static member variable that points to the this pointer and then use this with a wrapper function:
Now it becomes:
otherClass {
public:
void functionToBeCalled(unsigned int);
void initFunction();
static otherClass *otherPtr;
private:
myClass *blah;
}
initFunction()
{
blah->setFunction(wrapperFunc);
}
void wrapperFunc(unsigned int)
{
otherPtr->functionToBeCalled(int);
}
Surely there must be another way that I have missed/don''t know about?
Thanks in advance.