Chew please these lines:

set<string> set1; map<set<string>, int> map1; 

A newbie can't understand, map is [key, value], but here we are not putting anything into the map in the key, but adding words to set1. And after adding words, we can refer to them through map1. For example:

 `string lol; int k; cin >> lol; set1.insert(lol); map1[set1] = k;` 

And how to display them after. Displays the value of:

 cout << map1[set1] << endl; 

    1 answer 1

    "but here we are not putting anything into the map in the key" - here you are mistaken, the operator [] in the map just creates a new key-default value pair if there is no such key yet.

    • Add the words to the set, set the number k, for the key; map1 [set1] = k; For which key is the value of k then given? - Piter
    • @Piter for the operator [] specified in the argument, for the key copied from set1 , I mean VTT
    • Thank you, like slowly beginning to understand - Piter
    • In this regard, the @Piter map works unusually, in other containers, primarily in vector and simple arrays, to call the operator [], you must first add an element, and the operator itself will not do this. - VTT
    • And in this map it is impossible to derive the key-value as it were with map <string, int>. - Piter