Debian Codegraph @

yo/containers/examples/maptable.cc

raw
1 #include <iostream>
2 #include <iomanip>
3 #include <map>
4
5 using namespace std;
6
7 int main()
8 {
9 pair<string, int>
10 pa[] =
11 {
12 pair<string,int>("one", 10),
13 pair<string,int>("two", 20),
14 pair<string,int>("three", 30),
15 };
16 map<string, int>
17 object(&pa[0], &pa[3]);
18
19 for
20 (
21 map<string, int>::iterator it = object.begin();
22 it != object.end();
23 ++it
24 )
25 cout << setw(5) << it->first.c_str() <<
26 setw(5) << it->second << '\n';
27 }
28 /*
29 Generated output:
30 one 10
31 three 30
32 two 20
33 */