I just dont get what im doing wrong here. The goal is a finite state machine which changes the state and its behaviour depending on the char that it gets, but i can't get even the project structure down... here is the code i got so far, it wont complile, sorry i dont have the error codes, but one was definatley in the constructor of Automat where i tried to set the currentState to initial.
#ifndef Automat_H_
#define Automat_H_
class State;
class Automat {
public:
Automat();
virtual ~Automat();
void setCurrentState(State* newCurrentState);
void read(char c);
private:
State* currentState;
};
#endif /* Automat_H_ */
#ifndef STATE_H_
#define STATE_H_
class Automat;
class State {
virtual ~State();
virtual void read(char c, Automat* m) = 0;
};
#endif /* STATE_H_ */
#ifndef INITIAL_H_
#define INITIAL_H_
#include "State.h"
class Initial: public State{
virtual ~Initial();
void read(char c, Automat* m);
};
#endif /* INITIAL_H_ */
//Automat.cpp
#include "../includes/Automat.h"
Automat::Automat() {
currentState = new Initial();
}
Automat::~Automat() {
// TODO Auto-generated destructor stub
}
void Automat::read(char c){
//currentState->read(c, this);
}