error C2672: 'std::getline': no matching overloaded function found
error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)': expects 2 arguments - 3 provided
error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)': could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'int'
上面是浪费的我很长时间的一个错误,解决办法仅仅是包含一个头文件。
本以为包含string头文件就可以了,结果还需要另一个头文件sstream。
修改前:
#include <fstream> #include <iostream> #include <string> #include <random> #include <vector>
修改后:
#include <fstream> #include <iostream> #include <string> #include <sstream> #include <random> #include <vector>