I am trying to create an multimap of structs , i have declared a struct
struct Student{
Student(){};
Student( string n , int a ){
name = name;
age = age;
}
string name;
int age;
}
created a multimap
multimap< string , Student > classRoom;
and created a function that should push it in the multimap
void addStudent( string name , int age ){
Student tmp( name , age );
classRoom[ name ] = tmp;
}
if i use typical map
this works , but using multimap
this throws
error: no match for ‘operator[]’
Why is this happening and how can i fixt it? Moreover how does the implementation differ in these two?