digint/tinyfsm

How to separate state classes from the state machine class?

afkool opened this issue · 0 comments

It's been quite some time since I've developed cpp but I'm stuck on trying to separate out the state classes from the State Machine Class's cpp file. No matter how I rearrange the code, I get an expected class-name before '{' token error defining the state class.

Using the Elevator example, let's say I wanted to pull out the Panic state class into it's own file. How would I do that?

If I put the panic class into panic.hpp and include it in Elevator.hpp, then I get

In file included from elevator.hpp:5,
                 from elevator.cpp:3:
panic.h:3:1: error: expected class-name before ‘{’ token
    3 | {

The doc states

Note that the "elevator" example source code does not declare the states separately, but rather defines the code directly in the declaration.

So my question would be, how would I declare the states separately?

Thanks!