#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
using namespace std;
struct PoiDetails
{
int x;
std::string s;
};
int main()
{
struct PoiDetails oBj;
std::map<std::string, PoiDetails> vName;
oBj.x = 1; oBj.s = "str1";
vName["Jhon"] = oBj;
oBj.x = 2; oBj.s = "str2";
vName["Ben F"] = oBj;
oBj.x = 3; oBj.s = "str3";
vName["Shown"] = oBj;
oBj.x = 4; oBj.s = "str4";
vName["peter"] = oBj;
oBj.x = 5; oBj.s = "str5";
vName["juk"] = oBj;
oBj.x = 6; oBj.s = "str6";
vName["peter"] = oBj;
//std::set<std::string>::iterator it;
std::map<std::string, PoiDetails>::iterator it;
int i;
for(i=0, it=vName.begin(); (it!= vName.end()) && (i<6); i++, it++)
{
cout<<"Detail " << i << " ";
cout << it->first << "\t";
cout<<"x = "<< it->second.x <<"\t";
cout<<"s = "<< it->second.s <<"\n";
}
return 0;
}
I want to use multimap instead of "std::map<std::string, PoiDetails> vName;"
this is becoz, the key object "vName["peter"] = oBj;" is missing as the key has the same name occured twice.
Could you please let me know how I can use multimap to get rid of this.
Multimap for the given example worth helps a lot.
thanks well in advance