in a Project of mine i need to call a member/property (dont know the right term) of a struct by a string which is inside an array.
The fat part in the line with the comment //???? is the Problem users[i].members[j] is nonsense and i know that but i just cant figure out what would be right there.
Thanks for your help in advance :D
struct person { // Eigenschaften des Eintrags
string name; //nachname
string vorname; //vorname
string telefon; // telfonnummer
};
const int numbr_struct_att = 3;
const string members[numbr_struct_att] = { "name","vorname","telefon" };
cout << setw(5) << left << "Index" << setw(20) << left << "Name" << setw(20) << left << "Vorname" << setw(20) << left << "Telefon" << endl; // Header
for (int i = 0; i <= usernum; i++) {
cout << setw(5) << left << i+1;
for (int j = 0; j < numbr_struct_att; j++) {
cout << setw(20) << left << users[i].members[j] // ?????
}
cout << endl;
}