0

We can access one element by using find, but how can I traverse all the elements of the same key?

// unordered_multimap::find
#include <iostream>
#include <string>
#include <unordered_map>

int main ()
{
  std::unordered_multimap<std::string,std::string> mymap = {
     {"mom","church"},
     {"mom","college"},
     {"dad","office"},
     {"bro","school"} };

  std::cout << "one of the values for 'mom' is: ";
  std::cout << mymap.find("mom")->second;
  std::cout << std::endl;

  return 0;
}

0 Answers0