Finite State Machine in C++