Say I have this class:
class Object {
public:
int x;
int y;
void update(SDL_Event);
void start();
};
I want to be able to make start and update change behavior from instance to instance.
I have tried using function pointers, like so:
class Object {
public:
int x;
int y;
void (*update)(SDL_Event);
void (*start)(void);
};
void teststart() {
x++;
return;
}
And in my main(), I do:
testlevel.objs[1].start = teststart;
But then, I cannot reference variables from inside the class.
I am sure there is something obvious I am overlooking, but searching online yields no results for when the pointer is in the class.
Maybe function pointers are not the right answer?