您的位置:首页 > 其它

map容器

2015-08-20 09:59 183 查看
#include <map>
using namespace std;

void __fastcall TForm1::Button22Click(TObject *Sender)
{
   map<int ,AnsiString> myMap;//定义对象

   map<int ,AnsiString>::iterator it_find;//遍历指针

   myMap.insert(make_pair(1,"One"));//添加
   myMap.insert(make_pair(2,"two"));

   it_find = myMap.find(2);         //查找
   if(it_find != myMap.end())
   {
       it_find->second = it_find->second + " hello";//改写
       ShowMessage(it_find->second);                //读取
   }
   else
   {
       ShowMessage("未找到");
   }

   myMap.erase(1);//删除
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: