Having trouble printing out values in a map of maps

Hi guys, as the title states, I'm having some trouble going through a map of maps and printing out all of the values. Here is my declaration of the map:
 
map<T, map<T, int> > adjList;


And here is my Display function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
template<typename T>
void Graph<T>::display() const
{
	map<T, map<T, int> >::iterator iter;
	for (iter = adjList.begin(); iter != adjList.end(); ++iter)
	{
		cout << iter->first << endl;
		map<T, int>::iterator pos;
		for (pos = adjList[iter->first].begin(); pos != adjList[iter->first].end(); ++pos) 
		{
			cout << pos->first << "  " << pos->second << endl;
		}
	}
}


When I try to compile this, I get the follow error:
1
2
error C2679: binary '=' : no operator found which takes a right-hand operand of type 
'std::_Tree_const_iterator<_Mytree>' (or there is no acceptable conversion)


I'm pretty new to using iterators for this type of thing, and completely new to maps as well. Any help would be appreciated.
You could try replacing adjList[iter->first] by iter->second.

I don't know if there's any difference.
The function is marked as const so you probably have to use const_iterator.

map<T, map<T, int> >::const_iterator iter;

map<T, int>::const_iterator pos;
Yes, the problem was using a non-const iterator in a const function. Thanks.
Topic archived. No new replies allowed.