Okay, I am making a finite state machine for a lab. I have here a 2 files with the code for the FSM. I know it isn't finished yet, I know what needs to be put in. The only things I would need help on are the errors that I get.
void ChangeState(fsm_state *newState)<-//Here I had a const but when I added the m_currentState = newState it said that the value type cannot be assigned an entity type "fsm_state"
m_currentState = newState;
public:<-//Keeps saying I need a declaration
int loc = rand()%20;
if(loc >= 50)
ChangeState is inaccessible because it isn't inherited - the access modifier is private in the base class. It needs to be at least protected for the subclass to inherit it.
I made a FSM at the end of last year. I don't have the code to hand, but I created a StateMachine object that contained pointers to the previous and current state. In each iteration of the loop, it would run the current state's Update function.
The state was an abstract base class with Enter, Update and Exit functions. This allows you to apply "one-off" settings when you enter and leave states. It gives a bit more flexibility.
I don't have the code to hand for this, I'm afraid. I can tell you that Matt Buckland's "Programming Game AI by Example" was an excellent resource.