2

Is it possible to derive from an enum, if so how?

For instance:

enum eStandardTypes
{
    Type1 = 0,
    Type2,
    Unknown,
    Count,
};

enum eExtendedTypes : eStandardTypes
{
    Type3 = eStandardTypes::Count,
    Unknown,
    Count,
};
Bathsheba
  • 231,907
  • 34
  • 361
  • 483
Tim
  • 101
  • 9
  • 2
    I think you mean *inherit*. And no it's not possible. – Some programmer dude Jul 24 '17 at 08:59
  • Upvoted for intrigue. If it was good enough for a C++ standards discussion, then it's good enough to be asked here. – Bathsheba Jul 24 '17 at 09:00
  • @Someprogrammerdude That's what I meant. – Tim Jul 24 '17 at 09:02
  • @GainPaolo Did the search, nothing popped up that looked like this question, but it sure does look like a duplicate. – Tim Jul 24 '17 at 09:04
  • @GianPaolo you dont need to "downvote as duplicated" but just flag the question. Imho being a duplicate isnt a reason for downvote – 463035818_is_not_an_ai Jul 24 '17 at 09:04
  • @tobi303: Especially given that the OP clearly is not au fait with the terminology; do study the question edits. – Bathsheba Jul 24 '17 at 09:05
  • Can't create a class as showned at the [stated duplicate as](https://stackoverflow.com/a/644639/7880546) because of I am using an external (open sourced) library. That would break the conventions of that library. Made a comment as I agree on the duplicate. Gave me the answer too. – Tim Jul 24 '17 at 09:15
  • downvote removed – Gian Paolo Jul 24 '17 at 10:31

1 Answers1

6

No this is not possible, even with enum classes.

Support for inheritance of enum classes was discussed for C++17, but was not incorporated into that standard.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483