您当前的位置: 首页 >  c++
  • 0浏览

    0关注

    1477博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

c++ std::map find 用法

软件工程小施同学 发布时间:2021-08-31 17:33:15 ,浏览量:0

用find函数来定位数据出现位置,它返回的一个迭代器,

  • 当数据出现时,它返回数据所在位置的迭代器,
  • 如果map中没有要查找的数据,它返回的迭代器等于end函数返回的迭代器

#include

#include

#include

Using namespace std;

Int main()

{

       Map mapStudent;

       mapStudent.insert(pair(1, “student_one”));

       mapStudent.insert(pair(2, “student_two”));

       mapStudent.insert(pair(3, “student_three”));

       map::iterator iter;

       iter = mapStudent.find(1);

        if(iter != mapStudent.end())

        {

               Cout

关注
打赏
1665320866
查看更多评论
立即登录/注册

微信扫码登录

0.3756s