class valve
{
public:
valve();
protected:
private:
valvestate _state;
};
and initialize using constructor
valve::valve()
{
_state = opening;
}
compilation goes fine, but program doesn't work as expected. Seems like _state is not initialized.
Thanks ahead.
It's correct, but you don't want to have an enum like that. It means that no other variable can be named any of those, and "open" is a variable upon which you cannot rely on users not using. Make the enum declaration a public member of the class.