mickeyj
mickeyj

Reputation: 101

How to inherit typedef declarations for enum type

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?

Upvotes: 1

Views: 273

Answers (1)

edtheprogrammerguy
edtheprogrammerguy

Reputation: 6039

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

Upvotes: 1

Related Questions