you can have function objects, i.e., objects which behave like
functions with overloading the () operator. Define a base class like
"base_functor" and for each different function pointer, define a new
class which will store this function pointer and whose operator () will
take the same parameters as the function pointer and call the function
thru the stored pointer. the map can be of declared like
map<string,base_functor>. Try it out.

struct base_functor
{
 void operator () (void) { };
};

#define int (*FP)(int, char);

struct one_functor : base_functor {
 one_functor(): fp(NULL) {}
 one_functor(Fp f) : fp(f) {}
 int operator (int a, char b) {
    return fp(a,b);
 }
 private:
  FP fp;
};

and so on

map<string, base_pointer> myMap;

int foo(int a, char b)
{
  //does something
}

one_functor of(foo);

myMap["one"] = of;

etc

Will this solve your problem ?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to