Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to separate state classes from the state machine class? #33

Open
afkool opened this issue May 8, 2022 · 0 comments
Open

How to separate state classes from the state machine class? #33

afkool opened this issue May 8, 2022 · 0 comments
Labels

Comments

@afkool
Copy link

afkool commented May 8, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants