尝试打印 a map<string, vector<string>>
,但我不断收到错误消息:
prob2.cc: In function âvoid printMap(const std::map<std::basic_string<char>, std::vector<std::basic_string<char> > >&)â:
prob2.cc:42:36: error: cannot bind âstd::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}â lvalue to âstd::basic_ostream<char>&&â
In file included from /opt/centos/devtoolset-1.1/root/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/iostream:40:0,
我不知道这意味着什么,无法将 ostream 左值绑定到文件 iostream 中的 ostream&&。
void printMap(const map<string, vector<string>> &mymap)
{
for(auto const& i : mymap)
cout << i.first << endl << i.second << endl; //wanting to print out the vector of
} //strings belonging to each string key