enum inheritance

JS js.mdnq at gmail.com
Sun Jul 14 21:24:58 PDT 2013


It would be nice to be able to use enums in a hierarchical way:

enum colors
{
      enum Red { RedOrange, ... }
      enum Green { GreenBlue, ...}
      enum Blue { BlueYellow, ... }
...
}

which would be the same as the flattened version,

enum colors
{
    Red, RedOrange, ..., Green, GreenBlue, ..., Blue, BlueYellow, 
..., ...
}

but we could dereference such as

colors.Red.RedOrange,
colors.Blue,
colors.Green.GreenBlue,

(This isn't a great example but demonstrates what I would like to 
be able to do)

Is anything like this possible?



More information about the Digitalmars-d-learn mailing list