⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pr22014.cpp

📁 c++编程宝典源码及Quincy99编译器 是《标准C++编程宝典》电子工业出版社的光盘
💻 CPP
字号:
////////////////////////////////////////
// File Name: pr22014.cpp
////////////////////////////////////////
#include <iostream>
#include <map>

typedef std::map<int, char> MYMAP;

int main()
{
    // Create the map object.
    MYMAP charMap;

    // Populate the map with values.
    charMap[1] = 'A';
    charMap[4] = 'D';
    charMap[2] = 'B';
    charMap[5] = 'E';
    charMap[3] = 'C';

    // Display the contents of the map.
    std::cout << "Contents of map: " << std::endl;
    MYMAP::iterator iter;
    for (iter = charMap.begin();
            iter != charMap.end(); iter++)
    {
        std::cout << (*iter).first << " --> ";
        std::cout << (*iter).second << std::endl;
    }

    // Erase the map's second element.
    iter = charMap.begin();
    charMap.erase(++iter);

    // Display the new contents of the map.
    std::cout << "Contents of new map: " << std::endl;
    for (iter = charMap.begin();
            iter != charMap.end(); iter++)
    {
        std::cout << (*iter).first << " --> ";
        std::cout << (*iter).second << std::endl;
    }

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -