Is there a pattern where I can inherit enum from another enum in C++??
Something like that:
enum eBase { one=1, two, three }; enum eDerived: public eBase { four=4, five, six };
#include <iostream> #include <ostream> class Enum { public: enum { One = 1, Two, Last }; }; class EnumDeriv : public Enum { public: enum { Three = Enum::Last, Four, Five }; }; int main() { std::cout << EnumDeriv::One << std::endl; std::cout << EnumDeriv::Four << std::endl; return 0; }
1.4m articles
1.4m replys
5 comments
57.0k users