c++ - 为什么这里会报”没有与参数列表匹配的 重载函数 "getline" 实例“ 的错误?
PHP中文网
PHP中文网 2017-04-17 14:50:17
0
1
1616

我在把C++primer中的433页代码照着敲到vs2015后,出现以下问题。

#include<vector>
#include<string>
#include<map>
#include<memory>
#include<set>

class QueryResult;
class TextQuery {
public:
    using line_no = std::vector<std::string>::size_type;
    TextQuery(std::ifstream&);
    QueryResult query(const std::string&) const;
private:
    std::shared_ptr<std::vector<std::string>> file;
    std::map <std::string, std::shared_ptr<std::set<line_no>>> wm;
};

TextQuery::TextQuery(std::ifstream &is) :file(new std::vector<std::string>)
{
    std::string text;
    while (getline(is, text)) {//这里getline会标红,出现前面所述的错误
        file->push_back(text);
        int n = file->size() - 1;
        istringstream line(text);//这里line会标红,报错:不允许使用不完整的类型
        std::string word;
        while (line >> word) {//这里>>会标红:禁止显示状态
没有与这些操作数匹配的 ">>" 运算符    


        }
    }
}
PHP中文网
PHP中文网

认证0级讲师

membalas semua(1)
刘奇
#include <fstream>    // file stream
#include <sstream>    // string stream
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!