设为首页 加入收藏

TOP

map容器对象插入数据的4方式
2014-07-19 23:03:30 来源: 作者: 【 】 浏览:73
Tags:map 容器 对象 插入 数据 方式

  map容器对象插入数据的4种方式

  #include 

  #include  

  #include  

  #include  

  using  namespace  std;

  int  main()

  {

       map Employee;

       //通过键值赋值

       Employee[123] = "Mayuefei";

       //通过成员函数insert和STL的pair赋值

       Employee.insert(pair(132, "Liaoyuanqing"));

       //通过value_type赋值

       Employee.insert(map::value_type(124, "Liyiyi"));

       //通过make_pair赋值

       Employee.insert(make_pair(234, "LLK.D"));

       for ( map::iterator  it =  Employee.begin(); it !=  Employee.end(); it++)

      {

          cout<<(*it).first<<":"<<(*it).second<

      }

       system("pause");

       return 1;

  };

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++ map插入(insert)数据.. 下一篇C++ Primer的10.3.9单词转换

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·CPython是什么?PyPy (2025-12-26 06:50:09)
·Python|如何安装seab (2025-12-26 06:50:06)
·python要学习数据分 (2025-12-26 06:50:03)
·每日一道面试题-多线 (2025-12-26 06:20:17)
·java项目中哪些地方 (2025-12-26 06:20:14)