enum with classes/structs

Simen kjaeraas simen.kjaras at gmail.com
Thu Mar 10 11:24:01 PST 2011


useo <useo at start.bg> wrote:

> Hey guys,
>
> is it possible to declare a enum where all entries are instances of a
> class (or struct), like the following:
>
> class a {
>    ...
>    public this(uint i) {
>      ...
>    }
>    ...
> }
>
> enum myEnum : a {
>    entry1 = new a(0);
>    entry2 = new a(1);
> }
>
> ... or does enumerations only support constant-expressions? Thanks!

Only constant expressions, sorry.

-- 
Simen


More information about the Digitalmars-d-learn mailing list