Maps inside of Maps

i have a map which has another map inside of it
1
2
  
  map<string, map<string, int> > SubjectCode;


after adding all the values inside how to i iterate through it ?
Just like any other map: range for loop, for_each, or a for loop from begin() to end(). And in that loop, another one that iterates the same way over the nested map:

1
2
3
4
5
6
7
for(auto& p1: SubjectCode)
{
    std::cout << p1.first << " =>\n{\n";
    for(auto& p2 : p1.second)
        std::cout << "    " << p2.first << " -> " << p2.second << '\n';
    std::cout << "}\n";
}
im a little confused on what auto does ?
when i try to compile my code using what u provided i get this

error: a function-definition is not allowed here before ‘:’ token
Topic archived. No new replies allowed.