stl中map的使用
2016-03-28 00:00
176 查看
搞不懂他们为什么喜欢用pair刚刚在vs2010中测试了map。插入数据和查询数据的方法:
map<string,HWND> m; HWND hh = NULL; std::pair<string,HWND> p; p.first = "a"; p.second = hh; m["a"] = hh; HWND hwnd = m["a"]; if (hwnd) { cout<<"hello world"<<std::endl; } //下面的方式明显简单多了 map<string,int> m2; m2["a"] = 21; int s = m2["a"]; map<int,string> m3; m3[2] = "asd"; //遍历还是一样 map<string,int>::iterator it=m2.begin(); for(;it!=m2.end();++it) cout<<"key:"<<it->first <<"value:"<<it->second<<std::endl;
相关文章推荐
- ant nutch报错
- PHP 二分法
- 关于php中一些字符串的一些面试题的总结
- MySQL数据库的热备份和冷备份
- 对象池common-pool2源码分析
- 通过curl的并发机制实现php批量下载
- PHP sprintf() 函数
- appfog mongodb 导入数据
- ecshop 获取所在商品的顶级分类ID及NAME
- 新手如何快速入门node.js
- tasklist的坑
- 最近写的小程序
- 后台后避免重新登录
- 常用正则表达式
- 笑傲大数据时代,你必须要知道的41个Scala实战技能!
- git 遇到fatal:multiple stage entries for merged file
- 解决Eclipse 更新慢问题
- SHELL执行的三种模式
- WWW基本概念
- Apache简介