gpt4 book ai didi

c++ - '<' token 之前的预期模板名称

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:52:34 26 4
gpt4 key购买 nike

我是 C++ 的新手。尝试将基于 Windows 的程序移植到 Linux。我使用的平台是Ubuntu 13.03。编译器是 g++。

这是有问题的代码。

class CMapIDNames : public map< IDKey, string, CIDKeyLess >
{
} mapOfIDNames;

错误是:

error: expected template-name before ‘<’ token

试图包括 <functiontal> , 和 namespace::std , 没有帮助。

最佳答案

您需要包括 <map>并引用为std::map .您似乎还缺少 <string>标题。

#include <map>
#include <string>

class CMapIDNames : public std::map< IDKey, std::string, CIDKeyLess >
{
};

但请注意,标准库容器不是为公共(public)继承而设计的。你当然不应该多态地使用它们。

关于c++ - '<' token 之前的预期模板名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21562653/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com