Mar 11, 2013 at 5:06pm UTC
Is there a method to initialize an array within a map container like this:
1 2 3 4 5 6 7
//...
map <string, double [3]> Grade;
// Grade["Bobby Jay"] = {67.8, 44.5, 20.8}; //Faulty Instruction
Grade["Bobby Jay" ][0] = 67.8; //Possible to avoid writing out each one?
Grade["Bobby Jay" ][1] = 44.5;
Grade["Bobby Jay" ][2] = 20.8;
//...
in just one line?
Or is it better to use a structure object like this:
1 2 3 4 5 6 7 8 9
//...
struct Hold{
double tile[3];
//...
}
Hold Percent = {67.8, 44.5, 20.8};
map <string, Hold> Grade;
Grade["Bobby Jay" ] = Percent;
//...
Last edited on Mar 11, 2013 at 5:07pm UTC
Mar 11, 2013 at 7:55pm UTC
Thanks Cubbi.
I tried out your solution, and apparently, my outdated compiler doesn't have the necessary = operator function.
I'm going to update my compiler and try again. If it doesn't work, I'll find some way to emulate the array within a map.