HashMap声明错误 [英] HashMap declaration error

查看:114
本文介绍了HashMap声明错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using namespace std;
using namespace stdext;

struct eqstr
{
	bool operator()(string s1, string  s2) const
	{
		return s1 == s2;
	}
};

this declaration is OK:

hash_map <string, vector<CountOfWrd>> hm;

////////////////////////////////////

but this one get errors with errors : C2039, C2061, C2065, C1003

hash_map <string, vector<CountOfWrd>, hash<string>, eqstr> hm;

推荐答案

报价:

hash_map< string, >,hash< string>,eqstr> hm;

hash_map <string,>, hash<string>, eqstr> hm;

第四个模板参数必须是分配器,请参见文档: ^ ].
而且,您使用的第三个模板参数没有提供所需的功能对象之一(类比较的能够比较两个元素值作为排序键以确定它们的相对顺序".

The fourth template parameter has to be an allocator, see the documentation: hash_map class at MSDN[^].
Moreover, the third template parameter you used does not provide one of the required function objects ("of class compare able to compare two element values as sort keys to determine their relative order").


这篇关于HashMap声明错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆