我想要一种方法,它需要一个字符串,并给出每个字符的字符频率并将其存储在二维数组或2D矢量中。当我运行代码时,我不断收到编译器错误,但我不确定它说的是什么。我已经对错误进行了一些研究,但仍然无法解决问题。我认为必须有某种头文件丢失或者是因为被引用的类不是我的。在向量上使用find()时发生编译器错误C++
vector<pair<char, int>> CaesarCypher::charFreqGen(string inputFileName)
{
string input = GetInputString(inputFileName);
vector<pair<char, int>> output;
for (auto c : input)
{
auto it = find(output.begin(), output.end(),[=](const pair<int, char>& p) {return p.first == c; });
if (it != output.end())
it->second++;
else
output.push_back(std::make_pair(c, 1));
}
return output;
}
这里是我recieving错误:
Error 1 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::pair<char,int>' (or there is no acceptable conversion) c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 3026 1 PA1_CaesarCypher
谢谢!它现在工作 – user977154