Insert value pair to int, double multimap : multimap insert « map multimap « C++ Tutorial






#include <iostream>
using std::cout;
using std::endl;

#include <map>

int main()
{
   std::multimap< int, double, std::less< int > > pairs; // declare the multimap pairs

   cout << "There are currently " << pairs.count( 15 )
      << " pairs with key 15 in the multimap\n";

   // insert two value_type objects in pairs
   pairs.insert( std::multimap< int, double, std::less< int > >::value_type( 15, 2.7 ) );
   pairs.insert( std::multimap< int, double, std::less< int > >::value_type( 15, 99.3 ) );

   cout << "After inserts, there are " << pairs.count( 15 )
      << " pairs with key 15\n\n";

   cout << endl;
   return 0;
}
There are currently 0 pairs with key 15 in the multimap
After inserts, there are 2 pairs with key 15








23.13.multimap insert
23.13.1.uses a multimap to store names and phone numbers.
23.13.2.Insert into multimap with key-value pair
23.13.3.Insert into multimap with make-pair function
23.13.4.Insert value pair to int, double multimap