A map is one of the associative containers of STL and stores elements formed by a combination of a key value and a mapped value, following a specific order. Maps are a part of the STL provided for us by C++.
In this recipe, we will see how we can easily use the inbuilt template library provided by C++ to create complex data structures. After the complex data structure is created, we can easily use it to store data and access it:
Open Visual Studio.
Create a new C++ project.
Add a source file called
Source.cpp
.Add the following lines of code to it:
#include <iostream> #include <map> #include <conio.h> using namespace std; int main() { map <string, int> score_list; score_list["John"] = 242; score_list["Tim"] = 768; score_list["Sam"] = 34; if (score_list.find("Samuel") == score_list.end()) { cout << "Samuel...