M
Marcel Müller
Hi,
is there any smart solution for something like sub classes of
enumeration types?
Let's say we have
enum A
{ Value1,
Value2,
Value3
};
enum B
{ Value1,
Value2,
Value3,
Value4,
Value5
};
then enum B can hold all values that A allows and a few more. (Of
course, they cannot exist in the same namespace or class because of the
duplicate names.)
An implicit conversion from A to B is also reasonable. OK, one should
not call this inheritance since the conversion is in the other direction.
Now I would like to define a type B with exactly that properties and
preferably without retyping all the values of A.
I could write classes with a limited set constant values but this has
several drawbacks. First of all no more automatic enumeration of the
values. But also A must no longer be defined as part of a C-API. And
last but not least I loose the automatic choice of the appropriate data
type.
How do others solve comparable tasks?
Marcel
is there any smart solution for something like sub classes of
enumeration types?
Let's say we have
enum A
{ Value1,
Value2,
Value3
};
enum B
{ Value1,
Value2,
Value3,
Value4,
Value5
};
then enum B can hold all values that A allows and a few more. (Of
course, they cannot exist in the same namespace or class because of the
duplicate names.)
An implicit conversion from A to B is also reasonable. OK, one should
not call this inheritance since the conversion is in the other direction.
Now I would like to define a type B with exactly that properties and
preferably without retyping all the values of A.
I could write classes with a limited set constant values but this has
several drawbacks. First of all no more automatic enumeration of the
values. But also A must no longer be defined as part of a C-API. And
last but not least I loose the automatic choice of the appropriate data
type.
How do others solve comparable tasks?
Marcel