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

Threaded View

  1. #7
    Join Date
    Nov 2010
    Posts
    105

    Question Re: How to pair/multimap <int, pointer to a function>?

    Thank you everyone! Following Lindley's suggestions I changed the code to
    Code:
    class myclass {
    
    multimap<int, mem_fun_t<void, myclass > > mm_fn;
    ...
    
    void afunction();
    ...
    
    void anotherfunction(int anint){
           mm_fn.insert(pair<int, mem_fun_t<void, myclass > >(anint, mem_fun(&myclass::afunction)));
    }
    
    }
    Now the compiler does not complain but I am not sure if this is legal or will work as intended (please see paragraph below).

    What I would like to do is to build a multimap at run time. In the beginning the program reads in a file telling it which integer points to which member function. One integer may point to one or more member functions. A multimap is built according to the file content. After that the program receives integer input and calls the corresponding member function(s) in the multimap. (I haven't got to this part - not sure if I am on the right track yet.)

    Please help. Thanks!
    Last edited by acppdummy; May 23rd, 2012 at 08:30 AM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured