Anyone knows a alternative to inheriting a enum and add more constants inside derived class?
Is it possible and it will work with switch and if?
Thanks
Anyone knows a alternative to inheriting a enum and add more constants inside derived class?
Is it possible and it will work with switch and if?
Thanks
There is no way to directly inherit an enum in C++.
But you can create a simple workaround:
Qt Code:
class MyEnumBase{ public: enum{ Symbol1, Symbol2 }; }; class MyEnumDerived : public MyEnumBase{ public: enum{ Symbol3 = Symbol2+1, Symbol4 }; };To copy to clipboard, switch view to plain text mode
ricardodovalle (27th February 2014)
Bookmarks