However, when I atempt to access an element of array(such as mp[0]) and print its children element, I get "the Process returned -1073741819 (0xC0000005)".
#include <unordered_map>
#include <string>
#include <iostream>
usingnamespace std;
int main()
{
constint m = 3;
unordered_map<string,bool> mp[m];
for (int i = 0; i < m; i++){
int num_items;
cout << "Num items in map " << (i + 1) << ": ";
cin >> num_items;
for(int j = 0; j < num_items; j++){
string s;
cout << "Map entry: ";
cin >> s;
mp[i].emplace(s, true);
}
}
for(auto &it : mp[0]) // note: better to be const auto&
cout << it.first << "\n";
}
Num items in map 1: 2
Map entry: hello
Map entry: world
Num items in map 2: 5
Map entry: goodbye
Map entry: cruel
Map entry: world
Map entry: it's
Map entry: over
Num items in map 3: 3
Map entry: walk
Map entry: on
Map entry: by
world
hello