vendredi 23 juin 2017

For in double map

I have the double map

map <string, set <string>> a;

and want to output that map in lexicographical order. I try following code:

map <string, set <string>> a;    
for (auto pair = a.begin(); pair != a.end(); pair++) {
    cout << pair->first << " - ";
    for (auto value = pair->second->begin(); value != pair->second->end(); value++) {
        cout << *value << " " << endl;
    }
}

But this code does not work. I get the error that pair must have pointer type. What's wrong?

Aucun commentaire:

Enregistrer un commentaire