CPP/STL/MultiMap

From ProgrammingExamples
< CPP
Revision as of 00:08, 15 June 2011 by Newacct (Talk | contribs)

Jump to: navigation, search

MultiMap.cpp

#include <iostream>
#include <map>
 
int main(int argc, char *argv[])
{
 
  std::multimap <int, double> MyMap;
 
  //create a mapping from "testone" to 111
  MyMap.insert(std::make_pair(1, 1.2));
 
  //create an iterator
  std::map<int, double>::iterator iter;
 
  iter = MyMap.find(1);
 
  if(iter == MyMap.end())
  {
    std::cout << "Not found." << std::endl;
  }
  else
  {
      std::cout << "Found: " << iter->second << std::endl;	
  }
 
  return 0;
}