我正在尝试编译我的头文件,但是我遇到了我无法弄清楚的错误.
我想创建一个包含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) 我在这个头文件的 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)