Is there any possibility to create an enum A
which inherits properties of enum B
and additionally provides possibility to extend elements?
Example:
Enum A
- one
- two
- three
Enum B:A
- four
Is there any possibility to create an enum A
which inherits properties of enum B
and additionally provides possibility to extend elements?
Example:
Enum A
- one
- two
- three
Enum B:A
- four
You can't, but if you manually create two base enums, the second with same labels and values of the first one, you can virtually "down cast" them on runtime like if they were inherited, this way (real code):
NoYes e1; // 0 No, 1 Yes
NoYesError e2; // 0 No, 1 Yes, 2 Error
e1 = NoYes::No;
e2 = e1+0; // Add zero to avoid compile error
info(strFmt("%1 %2", e1, e2));
e2 = NoYesError::Error;
e1 = e2+0; // Don't do that
info(strFmt("%1 %2", e1, e2));
Hope this helps.