实践如下:

#include <iostream>
#include <map>
#include <string>
#include <typeinfo>
using namespace std; int main() {
cout << "Map 测试" << endl; //int i =1;
string name("jack");
pair<int, string> pair1(, name);
pair<int, string> pair2(, "老张"); map<int, string> map1;
map1.insert(pair1);
map1.insert(pair1);
map1.insert(pair2); map<int, string>::iterator it;
for (it = map1.begin(); it != map1.end(); it++) {
cout << (*it).first << "->" << (*it).second << endl;
} pair<string, string> pair21("张三", "张三");
pair<string, string> pair22("老张", "老张"); map<string, string> map2;
map2.insert(pair21);
map2.insert(pair21);
map2.insert(pair22); map<string, string>::iterator it2;
for (it2 = map2.begin(); it2 != map2.end(); it2++) {
cout << (*it2).first << "->" << (*it2).second << endl;
} map2.erase("张三");
cout << "再次遍历" << endl;
for (it2 = map2.begin(); it2 != map2.end(); it2++) {
cout << (*it2).first << "->" << (*it2).second << endl;
} map2.insert(pair<string, string>("老张2", "老张2"));
cout << "再次遍历2" << endl;
for (it2 = map2.begin(); it2 != map2.end(); it2++) {
cout << (*it2).first << "->" << (*it2).second << endl;
} cout << "测试结束" << endl;
return ;
}

C++ Map实践的更多相关文章

  1. mybatis oracle 插入自增记录 获取主键值 写回map参数

    网上搜了好多文章照着弄都返回不了主键给map, 实践证明要在传入的map参数里写回插入的主键,要这样写 <selectKey resultType="java.lang.Integer ...

  2. Python笔记(二)

    python笔记 函数式编程 函数 函数是Python内建支持一种封装(将大段代码拆成函数) 通过函数的调用,可以将复制的任务分解. 函数式编程(Functional Programming) 计算机 ...

  3. C++ Primer 学习笔记_35_STL实践与分析(9)--map种类(在)

    STL实践与分析 --map类型(上) 引: map是键-值对的集合. map类型通常能够理解为关联数组:能够通过使用键作为下标来获取一个值,正如内置数组类型一样:而关联的本质在于元素的值与某个特定的 ...

  4. MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example 1.4 Labeling the Map

    MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example 1.4 Labeling the Map 一.前言 MapServer拥有非常灵活的标签 ...

  5. MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.2 Static Map with Two Layers

    MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.2 Static Map with Two Layers 一.前言 上一篇博客< ...

  6. MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.1 A map with single layer

    MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.1 A map with single layer 一.前言 开始MapServer用 ...

  7. 『实践』百度地图给map添加右键菜单(判断是否为marker)

      var map; var s;//经度 var w;//纬度 $(document).ready(function(){ $(".mune").load("jsp/c ...

  8. golang 多维哈希(map,hashmap)实践随笔

    有些场景使用多维哈希来存储数据,时间复杂度恒定,简单粗暴好用.这里记录一下. 如下是三维哈希的简单示意图,建议层数不要太多,否则时间久了,自己写的代码都不认识. 下图是三维哈希在内存的存储形式,has ...

  9. Golang高效实践之array、slice、map

    前言 Golang的slice类型为连续同类型数据提供了一个方便并且高效的实现方式.slice的实现是基于array,slice和map一样是类似于指针语义,传递slice和map并不涉及底层数据结构 ...

随机推荐

  1. 第二篇 HTML 常用元素及属性值

    常用元素及属性值 先和同学了解下,一部分常用的元素,区别以及属性,常用在哪里.   标签是由左右尖括号抱起来的,由开始标签开始,再由结束标签结束,里面内容则是元素,比如:<div>< ...

  2. mySql 的常用命令

    一.数据库操作 1.创建数据库 create database <数据库名>: -- 例如,创建test数据库,create database test; 2.查询所有的数据库 show ...

  3. ORACLE (BLOB、CLOB、NCLOB、BFILE)

    LOB类型 内置的LOB数据类型包括BLOB.CLOB.NCLOB.BFILE(外部存储)的大型化和非结构化数据,如文本.图像.视屏.空间数据存储.BLOB.CLOB.NCLOB类型 4.1 CLOB ...

  4. postgres使用pg_ctl 命令

    想要用pg_ctl等一系列的命令,需要配置环境变量: PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/pgsql/binexport PGDATA=/ ...

  5. Delphi 变量的作用域

  6. nginx配置详解---学校资料

    #配置worker进程运行用户 nobody也是一个linux用户,一般用于启动程序,没有密码 user nobody; #配置工作进程数目,根据硬件调整,通常等于CPU数量或者2倍于CPU数量 wo ...

  7. Python time、datetime、os、random、sys、hashlib、json、shutil、logging、paramiko、subprocess、ConfigParser、xml、shelve模块的使用

    文章目录: 1. time & datetime模块 2. os模块 3. random模块 4. sys模块 5. hashlib模块 6. json模块 7. shutil模块 8. lo ...

  8. 08Response

    1.功能:设置响应消息 1. 设置响应行 1. 格式:HTTP/1.1 200 ok 2. 设置状态码:setStatus(int sc) 2. 设置响应头:setHeader(String name ...

  9. h5转pb的两个坑

    1.需要加上如下设置,否则转换前后输出可能不一致,这个主要针对dropout.BN层训练测试不一致 from keras import backend as K K.set_learning_phas ...

  10. MySQL第二次安装随笔

    找到之前的MySQL的安装包,重新安装MySQL. 1.设置环境变量,win10的可以右键此电脑-属性,在系统变量Path中添加mysql文件bin的路径 2.修改配置文件mydefault.ini( ...