-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path73_Maps_STL.cpp
36 lines (25 loc) · 859 Bytes
/
73_Maps_STL.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// STL - Standard Template Libraries...!!
// Getting started with Maps !
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
// Map is an Associative array
map<string, int> marksMap;
marksMap["Raj"]= 99;
marksMap["Mike"]= 95;
marksMap["Dustin"]= 78;
marksMap.insert( { {"Jake" , 72}, {"Murphy", 43} } );
map<string, int> :: iterator iter;
for ( iter = marksMap.begin(); iter != marksMap.end() ; iter++)
{
cout << (*iter).first << " " << (*iter).second << "\n" ;
}
// The first represents "KEY" and the second represents a "VALUE" at that "KEY"
cout << "The size is: " << marksMap.size() << endl;
cout << "The max size is: " << marksMap.max_size() << endl;
cout << "The empty's return value is: " << marksMap.empty() << endl;
return 0;
}