错误:“&”令牌之前的预期“)”

Vogel_guo

我在下面的标题中遇到了构造函数签名的问题。编译器给我消息:

error: expected ')' before '&' token

但是我不知道为什么会发生此错误,我不认为原因是编译器指出了这一点。

#ifndef TextQuery
#define TextQuery

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

using std::ifstream;
using std::map;
using std::shared_ptr;
using std::set;
using std::string;
using std::istringstream;
using std::vector;

class TextQuery
{
    public:
        using line_no = vector<string>::size_type;
        TextQuery(ifstream &); //!!!!error: expected ')' before '&' token
    private:
        shared_ptr<vector<string>> file; //input file
        //map of each word to the set of the lines in which that word appears
        map<string, shared_ptr<set<line_no>>> wm;
};

//read the input file and build the map of lines to line numbers
TextQuery::TextQuery(ifstream &is) : file(new vector<string>)
{
    string text;
    while(getline(is, text)) { //for each line in the file
        file->push_back(text); //remember this line of text
        int n = file->size() - 1; //the current line number
        istringstream line(text); //separate the line into words
        string word;
        while(line >> word) { //for each word in that line
            //if word isn't already in wm, subscripting adds a new entry
            auto &lines = wm[word]; //lines id a shared_ptr
            if(!lines) //that pointer is null the first time we see word
                lines.reset(new set<line_no>); //allocate a new set
            lines->insert(n); //insert this line number
        }
    }
}

#endif
巴里

提示:这是怎么了?

#ifndef TextQuery
#define TextQuery

// ..

class TextQuery {
   // ...
};

#endif

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在“;”之前得到“错误:预期的']' 令牌”在C中声明数组时

尝试在cygwin中构建boost文件系统时出错:错误:“ &&”令牌之前的预期unqualified-id

如何在';'之前固定预期的标识符 令牌错误

嵌入式C代码无法解释的语法错误;预期...在“ {”令牌之前

C ++错误-预期在'。'之前的主表达式 令牌|

错误:“ <”令牌之前的预期模板名称

错误:“>”令牌之前的预期主表达式

错误:带有索引或迭代字符串的'<'令牌之前的预期初始化程序

错误:“:”令牌之前的预期“)”

我在“('令牌”之前收到错误“预期的声明说明符或'...'?

错误:预期在';'之前的';' 代币

C ++-错误:“ {”令牌之前的预期类名

'='令牌之前的预期符号

解决预期的“;” 在“ {”令牌之前

错误:“(”令牌之前的预期主表达式

'{'令牌错误之前的预期类名

调试之前,C ++错误“预期的非限定ID'('令牌”

cryptopp错误:预期在'{'令牌之前的'=',',',';','asm'或'__attribute__'

GCC模板:预期»(«之前»>«令牌

找不到我的错误!错误:“(”令牌之前的预期标识符

错误:“ =”令牌之前的预期非限定ID

错误:“ {”令牌之前的预期类名-似乎找不到任何包含的通函

错误:在'。'之前预期':',','或')'。代币

C ++错误:预期的主表达式在';'之前 使用Cmake的令牌

使用结构时“预期”;“,”或“或”)“之前”*“令牌”错误

构建错误 - '.' 之前的预期主表达式 令牌

在令牌内联程序集错误之前预期为 ')'

错误:';'、',' 或 ')' 在 '.' 之前 令牌?

“'{'令牌之前的错误预期表达式”