I want to get an iterator to struct variable to set a particular one on runtime according to enum ID. for example -
struct {
char _char;
int _int;
char* pcha
Nope. In C++ you normally do something like this for enums:
enum VarTypes {
vtChar = 0,
vtInt,
vtDouble,
vtFirst = vtChar,
vtLast = vtDouble
};
You would still need a switch block to set the members on the struct. If you feel so inclined have a look at some Variant implementation in Microsoft's code. That's kinda similar to what you are doing.