I declared a map of the form

map<pair<int,int>,int> net;

and inserted elements in the following way

net.insert( make_pair( make_pair(c1,c2 ),cost ));

I could access the second element (cost, in the above code) using iter->second. But, I want to know how to access the two elements that form the first pair in the map(i.e., c1 and c2 in the above example).


here you go:


I tried that, but it didn't work. I got the following error.

error: base operand of ‘->’ has non-pointer type ‘const std::pair<int, int>’

Thanks for the reply.