0

I have a pre-defined struct (unchangable)

struct ACCOUNT
{
    char IDAccount[MAX_IDACCOUNT_LENGTH];
    char fullName[MAX_FULLNAME_LENGTH];
    int type;
};

Now, I want to override the type of the type member variable. Is this a right way doing it?

enum ACCOUNT_TYPE {ACCOUNT_TYPE_SV, ACCOUNT_TYPE_CB, ACCOUNT_TYPE_OT};

struct Account : virtual ACCOUNT {
    ACCOUNT_TYPE type;
};

1 Answers1

2

Is this a right way doing it?

In your second definition you are just shadowing ACCOUNT::type. There's no way for you to modify the type of ACCOUNT::type (unless you modify the actual definition of ACCOUNT, which you defined as "unchangeable").

See this question if you want to cast the int to an enum instead.

Community
  • 1
  • 1
Shoe
  • 74,840
  • 36
  • 166
  • 272