小编New*_*his的帖子

错误:'list'不是'std'的成员而且error:template参数2无效

我正在尝试编译我的头文件,但是我遇到了我无法弄清楚的错误.

我想创建一个包含3个地图的结构:-map从单个单词到count -map从单词对到count -map从单个单词到下面单词列表

我的头文件中的代码:

#include <cstdlib>
#include <iostream>
#include <cstring>
#include <string>
#include <cctype>
#include <vector>
#include <algorithm>
#include <map>

typedef struct {

    std::map<std::string, int> firstCounts;
    std::map<std::string, int> pairCounts;
    std::map<std::string, std::list<std::string>> follows; //You can use an iterator to retrieve the values stored in the list. 

} LanguageModel;
Run Code Online (Sandbox Code Playgroud)

我得到的错误:

>   LangModel.h:24:23: error: ‘list’ is not a member of ‘std’
>      std::map<std::string, std::list<std::string>> follows; //You can use an iterator to retrieve the values stored in the list. 
>                            ^
>     LangModel.h:24:23: …
Run Code Online (Sandbox Code Playgroud)

c++ dictionary list std c++11

8
推荐指数
2
解决办法
1万
查看次数

错误:bool operator== 必须正好有两个参数

我在这个头文件的 FileDir 类中有一个 operator== 类成员:

#include <sstream>   

class FileDir {

public:   

    FileDir(std::string nameVal, long sizeVal = 4, bool typeVal = false);   

    FileDir(const FileDir &obj);   

    ~FileDir();            // destructor   

    long getSize() const;    

    std::string getName() const;   

    bool isFile() const;   

    std::string rename(std::string newname);     

    long resize(long newsize);    

    std::string toString();    

    bool operator== (const FileDir &dir1);        

private:

    std::string name;

    long size;

    bool type;

};
Run Code Online (Sandbox Code Playgroud)

这是实现:

bool operator== (const FileDir &dir1) {

    if (this->name == dir1.name && this->size == dir1.size && this->type == dir1.type)

        return true;

    else

        return …
Run Code Online (Sandbox Code Playgroud)

c++ class operator-overloading

-1
推荐指数
1
解决办法
6421
查看次数

标签 统计

c++ ×2

c++11 ×1

class ×1

dictionary ×1

list ×1

operator-overloading ×1

std ×1