I'm having problems updating a multimap. I need to change the key value. I have found various examples but none seem to work. Any help gratefully received.
Below a simplified map test bit of code. I had hoped the line between the commented asterisks would do the trick but seems not/
/*
Testing maps
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <list>
#include <string>
#include <time.h>
#include <map>
#include <vector>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[])
{
typedef map <string, string> MAP_STRING_MESSAGE;
MAP_STRING_MESSAGE::iterator ilocator1;
MAP_STRING_MESSAGE::iterator findlocator1;
MAP_STRING_MESSAGE amap;
amap.insert(make_pair("first","One"));
amap.insert(make_pair("second","Two"));
amap.insert(make_pair("third","Three"));
for ( ilocator1 = amap.begin(); ilocator1 != amap.end(); \
++ ilocator1 )
{
cout << ilocator1->first << "\n";
cout << ilocator1->second << "\n";
cout << "____________________________\n";
}
findlocator1 = amap.find("second");
// ************
findlocator1->first = "fourth";
// ************
for ( ilocator1 = amap.begin(); ilocator1 != amap.end(); \
++ ilocator1 )
{
cout << ilocator1->first << "\n";
cout << ilocator1->second << "\n";
cout << "____________________________\n";
}
getch();
}