Boost logo

Boost Users :

Subject: Re: [Boost-users] [statechart] Problem compiling a statemachine with "class" insteadof "struct"
From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2009-02-12 08:45:48


Hi Rudolf

[snip]
> If we instantiate a state like this:
>
> struct Active : public boost::statechart::simple_state< Active,
> PRX5StateMachine >
> {
> public:
> Active() : m_data("") {}
> ~Active() {}
>
> std::string & Data() { return m_data;}
>
> const std::string& Data() const { return m_data; }
>
> private:
> std::string m_data;
> };
>
> and use it in our code, everything compiles fine. As soon as we
> change the declaration to
>
> class Active : public boost::statechart::simple_state< Active,
> PRX5StateMachine >
>
> we get massive compiler errors, which look like this:
[snip error message]

> Is it mandatory to inherit from simple_state via a struct and not from a
> class?

As Igor has already pointed out (thanks, Igor!), you *should* be able to use
class instead of struct, as long as you ensure that everything needed by
Boost.Statechart is public. However, I'm a bit puzzled by your example code
above, as it does not contain any reactions typedef. Is that intentional? If
so, then just changing class to struct should not cause the errors you
report. If the amount of code is small (< 10k) you can post it here
otherwise please send me the code by private email, see below for
instructions.

By the way, please always add [statechart] to your subject line when asking
questions regarding Boost.Statechart. This will usually ensure a much
speedier response from me and also help other group members to filter the
messages they are interested in.

Regards,

-- 
Andreas Huber
When replying by private email, please remove the words spam and trap
from the address shown in the header. 

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net