令牌之前的预期模板名称'<'

expected template name before '<' token

本文关键字:lt 令牌      更新时间:2023-10-16

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

这是有问题的代码。

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

错误是:

错误:"&lt;"令牌之前的预期模板名称

尝试包括<functiontal>namespace::std,无济于事。

您需要包括<map>,并参考为std::map。您似乎还缺少<string>标头。

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

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