gpt4 book ai didi

c++ - 错误 : ‘list’ is not a member of ‘std’ and error: template argument 2 is invalid

转载 作者:可可西里 更新时间:2023-11-01 17:08:48 27 4
gpt4 key购买 nike

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

我想创建一个包含 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.

最佳答案

你忘了添加

#include <list>    

关于c++ - 错误 : ‘list’ is not a member of ‘std’ and error: template argument 2 is invalid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29401979/

27 4 0