📄 list7-18.cpp
字号:
// Listing 7-18
// This program demonstrates how a map collection can
// be initialized using the insert method and subsript
// operator.
#include<string>
#include<map>
#include<iostream>
#include <vector>
using namespace std;
pair<string,string> Object1("122.22.33.45","www.example1.map");
pair<string,string> Object2("122.33.44.55","www.example2.map");
pair<string,string> Object3("122.33.55.66","www.example3.map");
vector<pair<string,string> > Group;
pair<string,string> Temp;
void main(void)
{
Group.push_back(Object1);
Group.push_back(Object2);
Group.push_back(Object3);
map<string,string,less<string> > MapA;
MapA.insert(Group.begin(),Group.end());
MapA["122.77.66.77"] = "www.example4.map";
map<string,string,less<string> >::iterator P = MapA.begin();
while(P != MapA.end())
{
Temp = *P;
cout << "The key for MapA is " << Temp.first << endl;
cout << "The value for MapA is " << Temp.second << endl;
P++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -