Array of member functions
I want to implement a statemachine using an array of member function pointers instead of using switch-case statements:
This is the original situation:
I want to change the HandleState function to something like this:
Can anyone help me how I should declare the 'm_myStateHandlers' array? I should be a membervariable and all HandleState_... functions are not static.
Thanks in advance,
Declaration of m_myStateHandlers
This was not the problem, but I can not fill it up.
Response to the latest posts
Answer to 'homeyg':
I've tried something similar like you posted last. But I got compiler errors. I will verify my code against yours and test it again.
Answer to 'Dave_Sinkula':
This is an interesting alternative way of working! At first sight is seems very difficult to perform debugging on it (keeping the overview of the states in sight), but I will surely test this out.