I can't for the life of me figure out what to do. Basically, I have to use a nested map to store a series variables a, b, c. The first var a is the key, and the object is the nested map ( b, c, where b is the key of the nested map and c is the object of the nested map ). After some values were inserted into the map, I have to find a user specified variable a within the map. So, for instance, if a user wants to search all the records with the name "Eric" ( var a ), I have to display all the records with the a value "Eric".
I have to declare it like this :
Which would make : map< a, map<b, c> > my_map
Using outer and inner map not allowed. Using a multimap is not allowed.
Now comes the problem. I am supposed to input a few records with the same variable a. For instance :
It loops until you input anything other than y/Y . When prompted to input a value for a, I input "boob" 2 times. The problem is, it only records the first "boob", since a normal map doesn't allow duplicate keys. But I am supposed to input multiple keys with the value "boob".
I don't know how clearly I explained it, but basically I need to insert duplicate keys in a nested map.
I have to declare it like this :
typedef map < string, map<string, int> > my_map;
my_map map_find;
Which would make : map< a, map<b, c> > my_map
Using outer and inner map not allowed. Using a multimap is not allowed.
Now comes the problem. I am supposed to input a few records with the same variable a. For instance :
do
{
cout <<" a \n";
cin >> a;
cout <<" b \n";
cin >> b;
cout <<" c " <<endl
cin >> c;
map_find[name].insert = ( make_pair ( surname, tel_no ) );
cin >> choice;
}while ( choice == 'y' || choice == toupper('y') );
It loops until you input anything other than y/Y . When prompted to input a value for a, I input "boob" 2 times. The problem is, it only records the first "boob", since a normal map doesn't allow duplicate keys. But I am supposed to input multiple keys with the value "boob".
I don't know how clearly I explained it, but basically I need to insert duplicate keys in a nested map.