map with class as values

Hi all,

I'm wondering if i could create something like map<key,class> kind of template. if it's even possible? how would i access, say the variables in that class?
Why not? Just use the map like you would use it for a type of plain old data, only keeping in mind that what the [ ] operator will be giving you back is a reference to a class. Just like a vector!

-Albatross
Last edited on
hi sir,

could you provide me an example of access that particular class? I'm new in this so i'm not sure how to go about it.

say below

class student_info (){
int ID;
string name;
vector<int> studentGrade(10);
}

int main (){
map <key, (student_info Student1)> studMap

studMap[key].insert (how to access the various variables?)

}
Last edited on
Topic archived. No new replies allowed.