--- In [email protected], girish gandhi <girish_gandhi...@...> wrote:
> I want ot extend or inhertis enums.
You can't in standard C++, but you can probably do what you
want in several ways. Tell us why you want to do this, with
sample code and intended usage.
> But no idea how i can be .
Off the top of my head...
struct base
{
enum status_t
{
base_error_1,
base_error_2,
//...
base_error_count
};
int status;
};
struct derived1 : base
{
enum status_t
{
derived_error_1 = base::base_error_count,
derived_error_2,
//...
derived1_error_count
};
};
struct derived2 : base
{
enum status_t
{
derived2_error_1 = derived1::derived1_error_count,
derived2_error_2,
//...
derived2_error_count
};
};
Of course, this requires some methodical application and
maintenance, and it sacrifices some type safety.
In practice, I would simply declare all possible statuses
in the base status_t enum. Generally, there's no need to
restrict possible values to certain classes. That said,
you might have found one.
--
Peter