I have a struct Game with a function pointer called onBegin
struct Game {
// ...
void (*onBegin)(Game&);
// ...
};
What I am attempting to do is allow the user to create their own onBegin function, in which they could say
void CustomFunc(Game& g) {
// Do something
}
Game g = Game();
g.onBegin = *CustomFunc;
What I am attempting to do is make a function and then set the pointer onBegin to point at that default function.
struct Game {
public:
void (*onBegin)(Game&);
private:
void defualtOnBegin(Game&);
};
// In the constructor
Game::Game() {
// ...
this->onBegin = this->defaultOnBegin; // This is what is giving me the error
}
I receive the error: a pointer to a bound function may only be used to call the function and do not know what is wrong here.
static. It gets the instance by its parameter anyway.