我正在尝试编译我的头文件,但是我遇到了一些我无法弄清楚的错误。
我想创建一个包含3个地图的结构: - 从单个单词到计数的映射 - 从单词对到计数的映射 - 从单个单词到下列单词列表
我的头文件中的代码:
#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;
我得到的错误:
> 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: error: ‘list’ is not a member of ‘std’
> LangModel.h:24:38: error: template argument 2 is invalid
> 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:38: error: template argument 4 is invalid
> LangModel.h:24:44: error: expected unqualified-id before ‘>’ token
> std::map<std::string, std::list<std::string>> follows; //You can use an iterator to retrieve the values stored in the list.
答案 0 :(得分:14)
您忘了添加
#include <list>
答案 1 :(得分:4)
#include <list>
怎么样?您缺少标题包含。