C++ STL Map or Hash Table Implementation

C++ STL Map or Hash Table Implementation

Instructor-svgAl-Mamun Sarkar
Apr 03 , 2020

C++ STL Map or Hash Table Implementation. The following code shows how to use Map or Hash Table in C++ programming language.

 

Code:

#include <iostream>
#include <string>
#include <map>
using namespace std;

int main()
{
    map < string , string> m;

    m["name"] = "Md. Al-Mamun Sarkar";
    m["email"] = "test@example.com";

    cout << m["name"] << endl;
    cout << m["email"] << endl;
    
    cout << "Looping Map" << endl;
    for (auto& x: m) {
        cout << x.first << ": " << x.second << '\n';
    }

    return 0;
}

 

Output:

Md. Al-Mamun Sarkar
test@example.com
Looping Map
email: test@example.com
name: Md. Al-Mamun Sarkar

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram