Insert characters into map. : map insert « map multimap « C++ Tutorial






#include <iostream>
#include <string>
#include <map>

using namespace std;

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

  m.insert(pair<string, int>("A", 100));
  m.insert(pair<string, int>("G", 300));
  m.insert(pair<string, int>("B", 200));

  return 0;
}








23.6.map insert
23.6.1.Insert characters into map.
23.6.2.Use insert() to add an entry
23.6.3.Duplicate keys are not allowed in a map
23.6.4.Insert a pair using function make_pair
23.6.5.Insert a pair object directly
23.6.6.Insert using an array-like syntax for inserting key-value pairs
23.6.7.Insert key-value pairs into the map using value_type
23.6.8.use subscript operator to write value to a map
23.6.9.Insert value pair to map