;)
Hey guys, I have another simple question today:
Lets say I have a structure:
struct Info{
string name;
string id;
double telNum;
};
//....
Info person;
//....
Now, if I had a function in which I told it to output one of the elements in the structure, how would I go about doing this without doing something like the following:
void func(int i){
switch(!){
case 0:
//.... output name
case 1:
//.... output telnum
case 2:
//..... output ID
}
}
I'm wondering whether there was a way of doing this similar to the following:
void func(??? elem){
cout << person.[elem];
}
Hope you guys get the idea, thanks in advance.