Inherit enum members

Andrey saasecondbox at yandex.ru
Sun Apr 21 20:58:19 UTC 2019


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
> onlineapp.d(28): Error: cannot implicitly convert expression 
> "w2" of type string to Key
> onlineapp.d(29): Error: cannot implicitly convert expression 
> "e3" of type string to Key

How to understand this?


More information about the Digitalmars-d-learn mailing list