‘hash_map’ was not declared in this scope的解决方法

来源:互联网 发布:大数据应用系统架构 编辑:程序博客网 时间:2024/06/07 15:03

 ‘hash_map’ was not declared in this scope的解决方法


由于hash_map定义在__gnu_cxx命名空间中,故你必须在使用时限定名字空间__gnu_cxx::hash_map,或者使用using关键字加一个  using namespace __gnu_cxx;  如下所示:

#include <hash_map>
using namespace stdext;


要使用hash_set时,由于hash_set被包含在include/ext目录下,所以该头文件导入形式如下:
#include <ext/hash_map>
using namespace __gnu_cxx;