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:
Code:
map<T, map<T, int> > adjList;
And here is my Display function:
Code:
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:
Code:
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.