In my code I'm using multiple structs of the following structure:
struct Track {
string artist;
string cd;
// etc....
};
The structs can be referred to as: Track1, Track2, etc.
I'm trying to make a function that uses a variable to determine which member it should output.
For example:
string x ="cd"
cout << Track1.x << endl;
I can't really figure out how to do this... I keep getting the error that 'x' is not a member of the Struct.
Thanks for taking time to read this, I hope you can help me out.
if (x == "cd") return o.cd;?