|
-
May 23rd, 2012, 08:19 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|