|
本帖最后由 zhangcaiyun_86 于 2013-3-11 17:28 编辑
#include "stdafx.h"
#include <map>
#include <string>
#include <iostream>
using namespace std;
int main()
{
map<int, string> mapstudent;
pair<map<int, string>::iterator, bool> Insert_Pair;
Insert_Pair = mapstudent.insert(pair<int, string>(1, "student_one"));
if(Insert_Pair.second == true)
{
cout<<"Insert Successfully"<<endl;
}
else
{
cout<<"insert failure"<<endl;
}
Insert_Pair = mapstudent.insert(pair<int, string>(1, "student_two"));
if(Insert_Pair.second == true)
{
cout<<"Insert Successfully"<<endl;
}
else
{
cout<<"Insert Failure"<<endl;
}
map<int, string>::iterator iter;
for(iter = mapstudent.begin(); iter != mapstudent.end(); iter++)
{
cout<<iter->first<<" "<<iter->second<<endl;
}
cin.get();
}
运行结果:
Insert Successfully
Insert Failure
1 student_one ???为啥是这个运行结果捏
(单行都注释一下,不胜感激) |
|