我的代码在 main.cpp 中没有错误地工作,但突然间,我收到了这个错误:
/opt/lintula/gcc/include/c++/5.2.0/bits/stl_tree.h:2223: error: no match for ‘operator++’ (operand type is ‘std::__cxx11::basic_string<char>’)
for (; __first != __last; ++__first)
^
Run Code Online (Sandbox Code Playgroud)
我没有碰stl_tree.h,为什么会在那里发生错误?当我不知道从哪里开始时,我该如何调试这些类型的问题?
这是代码,我尝试以 name:points 的形式读取和插入数据到 std::map
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <fstream>
using namespace std;
int main()
{
map<string, string> piste_hakemisto;
string input_tiedosto;
cout << "Input file: ";
cin >> input_tiedosto;
ifstream tiedosto_olio(input_tiedosto);
if (not tiedosto_olio){
cout << "Error! The file " << input_tiedosto << " cannot be opened.";
return EXIT_FAILURE;
}
string nimi;
string pisteet;
string …Run Code Online (Sandbox Code Playgroud)