forked from Bhupesh-V/30-seconds-of-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
size.cpp
35 lines (28 loc) · 777 Bytes
/
size.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
/*
Author : Kabindra Shrestha
Date : Date format 25/10/2019
Time : Time format 12:28
Description : returns the size of the map, i.e. the number of elements in
the map
*/
#include <iostream>
#include <map>
// Prints the current size of the map
void printSize(std::map<char, int> &asciiMap){
std::cout << "Size of map (asciiMap.size()): " << asciiMap.size() << std::endl;
}
int main(){
std::map<char, int> asciiMap;
// creates a map
// adds four elements in the map
asciiMap['A'] = 65;
asciiMap['B'] = 66;
asciiMap['C'] = 67;
asciiMap['D'] = 68;
printSize(asciiMap);
// adds two elements in the map
asciiMap['E'] = 69;
asciiMap['F'] = 70;
std::cout << "\nAfter adding two more elements" << std::endl;
printSize(asciiMap);
}