Original Post
Hi, I'm having trouble finding info on how to pass a function as a pointer to a member function, this example will explain it more clearly: What would be the correct way to accomplish that? Thanks.
class Foo
{
public:
void SetRenderCallback(int (*SomeFunc)() )
{
m_Callback = SomeFunc;
}
void Render()
{
//call the callback
m_Callback();
}
private:
//somehow declaring a pointer to a function;
int (*m_Callback) ();
};
// another file
Foo FooClass;
int MyCallback();
FooClass.SetRenderCallback(&MyCallback);
FooClass.Render();