【发布时间】:2015-09-13 20:42:01
【问题描述】:
我的程序无法编译,因为它没有找到操作数的匹配项。 它访问 struct Student 中的地图,我不确定这是否是访问地图的确切方式。
我的程序无法编译,因为它没有找到操作数的匹配项。 它访问 struct Student 中的地图,我不确定这是否是访问地图的确切方式。
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <list>
using namespace std;
struct Student {
string id;
map<string, int> scores;
};
istream& operator >>(istream &is, Sudent& g) {
auto it = g.scores.begin();
is >> g.id >> it->first >> it.second;
return is;
}
在>> it->first 我得到这个错误:
Error: no operator ">>" matches these operands
operand types are: std::basic_istream<char, std::char_traits<char>> >> const std::string
【问题讨论】:
-
请将代码发布为文本而不是图像。
-
@CaptainObvlious:这怎么可能有远近于复制的地方?
-
查看istream的定义,运营商不行。