I am following this example. But when I compile, it returns an error:
Invalid use of non-static member function
at the line
void(Machine:: *ptrs[])() =
{
Machine::off, Machine::on
};
I tried to add static to void on(); at class
class Machine
{
class State *current;
public:
Machine();
void setCurrent(State *s)
{
current = s;
}
static void on(); // I add static here ...
static void off(); // and here
};
But it complains that
Invalid use of member Machine::current in static member function
Can you help me fix this?