I am trying to implement a dictionary where i have an outer map (as a multimap) with the key being the word being searched and the value being the inner map, which will have several pairs itself with different values which all can map to the outer multimap key.
for example: the word Distinct has several meanings depending if its a noun, verb, adjective, or pronoun ==> noun- A keyword in this program adverb- Uniquely. Written "distinctly" etc.
I am thinking of mapping the word Distinct as the key to the outer multimap and mapping the part of speech as the key to the inner map with the definitions as the inner map's values.
so far i declared the multimap as this:
typedef map<string, string> valMap;
multimap<string,valMap> myMultMap;
and i have tried adding values by using insert() like this:
myMultMap.insert("Diction", valMap.insert(pair<string,string>("fun", "first Value"));
I am just learning maps and still unsure as to the inner working of iterators in the maps. Any help would be greatly appreciated.
So first create the variable you need to insert:
valMap tmp;
tmp.insert(make_pair("fun", "first Value"));
Then insert this tmp
into the main map:
myMultMap.insert(make_pair("Diction", move(tmp)));