1

I am trying to inherit typedef declarations for enum type from base class in derived class

class Base{
public:
    enum Type{
        UNSPECIFIED = 0,
        TYPE1,
        TYPE2
    }
};

class Derived : public Base{
public:
    enum Type{
        UNSPECIFIED = 0,
        TYPE1,
        TYPE2,
        TYPE3
    }
};

How do we extend the enum type declaration in the derived class?

nakiya
  • 14,063
  • 21
  • 79
  • 118
mickeyj
  • 91
  • 7
  • You can't "extend" it. Once a type is defined, it's set in stone. However, `Derived` can define its own `enum Type`, but it's important to know that it is different from `Base::Type`. – Cornstalks Dec 17 '13 at 03:19

1 Answers1

1

You can't extend enums in C++ by inheritance. Not part of the language spec.

Some other ideas on how to do something like what you want here: Base enum class inheritance

Community
  • 1
  • 1
edtheprogrammerguy
  • 5,957
  • 6
  • 28
  • 47