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
No, C++ doesn't support this directly.
You can however do something very similar using boost::tuple:
enum { CHAR, //0 INT, //1 DBL //2 }; tuple t('b', 1, 3.14); int i = get(t); // or t.get()
You might also want to take a look at boost::variant.