特性
函数
示例
1 #include <iostream> 2 #include <string> 3 #include <map> 4 using namespace std; 5 6 int main(){ 7 map<int, string> mapStudent; 8 mapStudent.insert(pair<int,string>(1,"stu_1")); 9 mapStudent.insert(pair<int,string>(2,"stu_2")); 10 mapStudent.insert(pair<int,string>(3,"stu_3")); 11 12 map<int,string>::iterator iter; 13 iter = mapStudent.find(1); 14 if(iter != mapStudent.end()) 15 cout<<"Find, the value is"<<iter->second<<endl; 16 else 17 cout<<"Do not Find"<<endl; 18 return 0; 19 }
参考
c++ 容器函数详解
https://zouzhongliang.com/index.php/c-biaozhunmobankustlgehanshuxiangjie/
C++中的STL中map用法详解
https://www.cnblogs.com/fnlingnzb-learner/p/5833051.html
原文:https://www.cnblogs.com/cxc1357/p/12625599.html