updating maps
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: updating maps

Threaded View

  1. #1
    Join Date
    Mar 2009
    Posts
    48

    updating maps

    Hi all

    Having probs updating the key of a multimap record. I've tried various examples from here and there but no luck using mingw 3.4.2 Everything apart from update of key works (insert, erase, find ...) So below a simplified example, with between commented asterisks just one of my attempts of where the problem is.

    As always any guidance greatly appreciated

    Code:
    /*
    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;
    	typedef multimap <string, string> MMAP_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();	
    }
    Last edited by nigelhoath; August 5th, 2009 at 10:50 AM. Reason: correction

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center