nested enum

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

    #1

    nested enum

    Is it possible to do a nested enum?
    For example,
    private enum inside0{a,b,c}
    private enum inside1{d,e,f}
    private enum outside{inside0 , inside1}

    outside _variable=outsi de.inside0.a; //error here, but want a similar way

    Is it possible to set the _variable in the way similar to the above?
    Thanx


  • IchBin

    #2
    Re: nested enum

    a wrote:[color=blue]
    > Is it possible to do a nested enum?
    > For example,
    > private enum inside0{a,b,c}
    > private enum inside1{d,e,f}
    > private enum outside{inside0 , inside1}
    >
    > outside _variable=outsi de.inside0.a; //error here, but want a similar way
    >
    > Is it possible to set the _variable in the way similar to the above?
    > Thanx
    >
    >[/color]
    I do not have the answer but I would recommend you ask this question in
    the comp.lang.progr ammer newsgroup.

    --


    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA http://weconsultants.servebeer.com
    _______________ _______________ _______________ _______________ ______________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)

    Comment

    • Oliver Wong

      #3
      Re: nested enum


      "a" <a@mail.com> wrote in message news:LPOQe.3313 80$5V4.307125@p d7tw3no...[color=blue]
      > Is it possible to do a nested enum?
      > For example,
      > private enum inside0{a,b,c}
      > private enum inside1{d,e,f}
      > private enum outside{inside0 , inside1}
      >
      > outside _variable=outsi de.inside0.a; //error here, but want a similar
      > way
      >
      > Is it possible to set the _variable in the way similar to the above?[/color]

      There's a fundamental misunderstandin g about enums here. In the above
      example, no nesting is occuring. In the outer namespace, you have an enum
      called "inside0", and inside the namespace of the enum outside, you have an
      instance called "inside0". The code above is similar to this:

      public class inside0 {
      public final inside0 a = new inside0();
      public final inside0 b = new inside0();
      public final inside0 c = new inside0();
      }

      public class inside1 {
      public final inside1 d = new inside1();
      public final inside1 e = new inside1();
      public final inside1 f = new inside1();
      }

      public class outside {
      public final outside inside0 = new outside();
      public final outside inside1 = new outside();
      }

      As you can see from this code, you have a class named inside0, and you have
      a field named inside0, and they each refer to distinct things.

      - Oliver


      Comment

      Working...