我有一个map<string, list<int> >
我想遍历列表并打印出每个数字。我不断收到关于 const_iterator 和迭代器之间转换的编译错误。我做错了什么?
for (map<string, list<int> >::iterator it = words.begin(); it != words.end(); it++)
{
cout << it->first << ":";
for (list<int>::iterator lit = it->second.begin(); lit != it->second.end(); lit++)
cout << " " << intToStr(*lit);
cout << "\n";
}
error: conversion from
‘std::_Rb_tree_const_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::list<int, std::allocator<int> > > >’
to non-scalar type
‘std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::list<int, std::allocator<int> > > >’
requested|