Re: Inherit enum members

2019-04-21 Thread Alex via Digitalmars-d-learn
On Sunday, 21 April 2019 at 20:58:19 UTC, Andrey wrote: Hello, I have got 2 enums. How to inherit one enum from another? enum Key : string { K1 = "qwerty", K2 = "asdfgh" } enum ExtendedKey : Key { E1 = "q1", E2 = "w2", E3 = "e3" } Result: onlineapp.d(27): Error: cannot imp

Re: Inherit enum members

2019-04-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 21 April 2019 at 20:58:19 UTC, Andrey wrote: I have got 2 enums. How to inherit one enum from another? You don't. enums don't inherit, but rather have a base type. That means each enum member must match that base type and the compiler is looser about conversions between them, but t

Inherit enum members

2019-04-21 Thread Andrey via Digitalmars-d-learn
Hello, I have got 2 enums. How to inherit one enum from another? enum Key : string { K1 = "qwerty", K2 = "asdfgh" } enum ExtendedKey : Key { E1 = "q1", E2 = "w2", E3 = "e3" } Result: onlineapp.d(27): Error: cannot implicitly convert expression "q1" of type string to Key on