I'm stuck accessing a 2D map
How do I retrieve data out of the inner map?

map <string, map <int, class> > myMap

When I set up and iterator it, I get a std::pair.
it->second should yield a pair aswell because it points to map <int, class>
but I can't make a std::pair out of it->second.

it->second isn't recognized as a pair.

I'm not sure what the keyword "class" is doing in your map declaration, but using "int" would work like this:

#include <iostream>
#include <string>
#include <map>
using namespace std;

typedef map<int, int>              t_map_inner;
typedef t_map_inner::iterator      it_inner;
typedef map<string, t_map_inner >  t_map_outer;
typedef t_map_outer::iterator      it_outer;

int main() {
    t_map_outer m;
    m["abc"][3] = 5;
    m["abc"][7] = 2;
    m["def"][4] = 7;

    for (it_outer i = m.begin(); i != m.end(); ++i) {
        cout << i->first << '\n';
        for (it_inner j = i->second.begin(); j != i->second.end(); ++j)
            cout << "  " << j->first << ", " << j->second << '\n';
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.