2

I have a struct declared as follows:

struct X
{
int a;
long b;
string c;
}

I want to define a map in which key should exactly match with parameters of struct X. For e.g. key can 'a', 'b' or 'c' but not 'A' or 'bb' etc. One way I think of is to use key data type as a string and check if the string matches with variable names in struct X. Is there a better way to do this?

Moreover, in this case, map should have a value data type which matches with the key parameter. For e.g. if the key is 'a' then the value must have int datatype, if the key is 'c' then the value should have a string data type. How can I achieve this?

Is there a better way to design this entirely differently?

0

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.