nested enum

Cauterite via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 25 03:23:23 PDT 2016


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