enums

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • guyvo

    #1

    enums

    hi,

    I was glad to hear that v1.5 the enum class was introduced. I have a piece
    of code

    public class Input{
    public enum Condition {open,close}
    private Condition State;

    Input (Condition state){State = state;};

    protected void SetState (Condition state){State = state;};
    protected Condition GetState(){retu rn State;};


    }

    The compiler gives me the following error :

    "enum declarations allowed only in static contexts"

    The enum in this example is just used as a type to my variable.
    What is wrong here?
    What purpose does it have than in respect to other langauges like C ?


  • Jan Thomä

    #2
    Re: enums

    Is that "Input" an inner class by coincidence ? This would explain the error
    msg, because you cannot do any static declaration in an inner class...

    Best regards,
    Jan

    guyvo wrote:
    [color=blue]
    > hi,
    >
    > I was glad to hear that v1.5 the enum class was introduced. I have a piece
    > of code
    >
    > public class Input{
    > public enum Condition {open,close}
    > private Condition State;
    >
    > Input (Condition state){State = state;};
    >
    > protected void SetState (Condition state){State = state;};
    > protected Condition GetState(){retu rn State;};
    >
    >
    > }
    >
    > The compiler gives me the following error :
    >
    > "enum declarations allowed only in static contexts"
    >
    > The enum in this example is just used as a type to my variable.
    > What is wrong here?
    > What purpose does it have than in respect to other langauges like C ?[/color]

    --
    _______________ _______________ ________
    insOMnia - We never sleep....

    Comment

    Working...