Given this popular solution for "enum inheritance" (probably dubbed "extension"), would it be possible to raise a compiler error if I override the identifier of the base class enumerator in the derived class?
Example:
struct Enum
{
enum
{
One = 1,
Two,
_last
};
};
struct EnumDeriv : Enum
{
enum
{
Three = Enum::_last,
Four,
One
};
};
Live demo
What happens is that EnumDeriv::Onemasks (is that the right term?) Definition Enum::One. So, EnumDeriv::Onenow it will display the "unexpected" integer value 5.
This can create some hard-to-debug errors if we exit Enumand inadvertently redefine some of its enumerator identifiers.
, "" "enum inheritance", , .