   Function  Pointer Question
  So, I have a linked list of Pointers to Functions in a class like so struct FunctionList{unsigned int CurrentTime;int TimeLimit; //How many times to call the functionvoid (*Function)();char * name;FunctionList * next;FunctionList * prev;FunctionList(void){next = 0;prev =0;};FunctionList(char * Name ,void (*FunctionPtr)(), int Timelimit){Function = FunctionPtr; name = Name;next = 0;prev =0; TimeLimit= Timelimit; currenttime =0;}};How can I have get the function pointer to point to any function regardless of what that functions parameters are. Since I am not very good at explaining there is an example of what I mean below.---------------------------------------------------/*Just adds 2 dynamically allocated FunctionList structs to Linked List*///add Function that has (int,int) parametersAddFunctionToList(new Functionlist("Function Name", Add(3,5)));//add Function that has (int) parameterAddFunctionToList(new FunctionList("Another Function,  Square(5)));-----------------------------------------------------Any help on how I would do that(example) would be great![edited by - 101 on August 4, 2003 7:55:24 PM]
  You can''t. Period. The C standard does not allow conversions between function pointer types. ;  I think you can convert them to void*, however. just be careful, you''re playing with fire. ;  Question:Where are you going to store the parmeters?I think your better off having one function type.void(fp*)(void *);then store a struct of params with the function when you add it to your list.AddFunctionToList(new FunctionList("FuncOne", FuncOne, &global_int)); //note this does not have the time stuff there.Does this help? ;  This won''t help at all, but I find function pointers, along with templates, to be the greatest features of C++   Wizza Wuzza? ;  See Loki::Functor or Boost::Function The Loki Functor is polymorphic and has full-value-semantics.I can't say with authority what Boost::Function is capable of.- Magmai Kai Holmlor"No, his mind is not for rent to any god nor government" -  Rush, Tom Sawyer[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ][Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ | wxWindows| Spirit(xBNF)][Free C Libraries | zlib ] [edited by - Magmai Kai Holmlor on August 5, 2003 1:08:33 AM]