nested enum

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 25 03:36:21 PDT 2016


Btw, tehre is no need for extra semicolon (`;`) after enum and struct 
definition


Dne 25.8.2016 v 12:23 Cauterite via Digitalmars-d-learn napsal(a):
> On Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote:
>>
>
> Well those other answers aren't wrong, but I envisioned that you'd 
> have multiple categories within your sub-enums and whatnot, so you'd 
> need something more like this:
>
> struct A {
>     enum X {
>         one,
>         two,
>         three,
>     };
>     enum Y {
>         four = X.max + 1,
>         five,
>         six,
>     };
>     enum Z {
>         seven = Y.max + 1,
>         eight,
>         nine,
>     };
> };
>
> Continuing each enumeration from the end of the previous ensures you 
> won't get any fields with the same values.



More information about the Digitalmars-d-learn mailing list