map-begin

////////////////////////////////////////
//      2018/04/30 12:14:50
//      map-begin

// returns an iterator to the first element
#include <iostream>
#include <map>

using namespace std;

int main(){
    typedef map<int, char, less<int>> M;
    typedef M::value_type v_t;
    M m;

    m.insert(v_t(2,'B'));
    m.insert(v_t(3,'C'));
    m.insert(v_t(1,'A'));

    M::iterator it = m.begin();
    cout << "m:" << endl;
    while (it != m.end()){
        cout << it->first << "-" << it->second << endl;
        it++;
    }
    return 0;
}


/*
OUTPUT:
    m:
    1-A
    2-B
    3-C
*/ 
posted @ 2018-05-01 15:15  老耗子  阅读(44)  评论(0编辑  收藏  举报