博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux包括hash_map和hash_set的not declared问题
阅读量:7138 次
发布时间:2019-06-28

本文共 962 字,大约阅读时间需要 3 分钟。

当在Linux下cpp文件包括hash_map或hash_set时。会出现"‘hash_map’ was not declared in this scope"问题。

#include 
#include
#include
using namespace std;int main(void){ hash_map
hmap; hmap[1] = "hi hdu1"; hmap[2] = "hi hdu2"; hmap[3] = "hi hdu3"; hash_map
::iterator iter; iter = hmap.find(2); if (iter != hmap.end()) { cout << iter->second << endl; } else { cout << "not find" << endl; } return 0;}

原因:hash_map是声明在__gnu_cxx命名空间的,所以仅仅要在程序中加入using namespace __gnc_cxx就能够了^_^

#include 
#include
#include
using namespace std;using namespace __gnu_cxx;int main(void){ hash_map
hmap; hmap[1] = "hi hdu1"; hmap[2] = "hi hdu2"; hmap[3] = "hi hdu3"; hash_map
::iterator iter; iter = hmap.find(2); if (iter != hmap.end()) { cout << iter->second << endl; } else { cout << "not find" << endl; } return 0;}

转载地址:http://kfvrl.baihongyu.com/

你可能感兴趣的文章
YeoMan 与Angularjs
查看>>
Hibernate一级缓存 & 二级缓存(转)
查看>>
cigarettes
查看>>
连接php/mysql
查看>>
MVC前后台获取Action、Controller、ID名方法 以及 路由规则
查看>>
Windows下免安装版多Tomcat5多服务配置多启动(Tomcat6可参考)
查看>>
PHP安全性漫谈分享
查看>>
js jquery 判断当前窗口的激活点
查看>>
python基础学习笔记-切片难点
查看>>
简单上传图片到阿里云OSS
查看>>
中间件发展
查看>>
简析MonoTouch工作原理
查看>>
Eclipse中Spring插件的安装
查看>>
Unity3d导出安卓版本
查看>>
LAMP第四部分mysql操作
查看>>
Python之旅.第九章.并发编程
查看>>
复习模块
查看>>
Codeforces 691C Exponential notation(模拟)
查看>>
spring-excel-导出
查看>>
利用jenkins打造通过自定义参数更新svn 指定文件任务
查看>>