P
paul
Hi,
I have seen the use of static member functions for callbacks by
passing the name of the static member function and the this pointer to
the code that will call back.
I was thinking the same can be achieved by using member function
pointers and the this pointer.
E.g.
void FuncThatWillCallback( MyClass::staticFunc, (void *)this)
{
staticFunc(this);
}
void FuncThatWillCallback( PtrToMemberFunc, (void *)this)
{
this->PtrToMemberFunc;
}
Is there a reason why the static member function trick is so widely
used? (Except when FuncThatWillCallback is part of a 3rd party lib).
I have seen the use of static member functions for callbacks by
passing the name of the static member function and the this pointer to
the code that will call back.
I was thinking the same can be achieved by using member function
pointers and the this pointer.
E.g.
void FuncThatWillCallback( MyClass::staticFunc, (void *)this)
{
staticFunc(this);
}
void FuncThatWillCallback( PtrToMemberFunc, (void *)this)
{
this->PtrToMemberFunc;
}
Is there a reason why the static member function trick is so widely
used? (Except when FuncThatWillCallback is part of a 3rd party lib).