Function Pointer

I want to use some functions as arguments for another function.
I found out that it can be done using function pointers.

But the pointer must have the same type of argument and return values as the function being passed to it and I have 3 different functions with different arguments and/or return types.

Is there a way to make pointer to b able to point to various types of functions (without overloading the function)?
Last edited on
How would you call the function? How would you know from the pointer how many arguments need to be passed?
How would you call the function? How would you know from the pointer how many arguments need to be passed?

I know that it is possible for any one given function's structure, but I don't know if it is even possible for over two entirely different functions.
But if there is just one function:
void Func( int (*func) (Date,int), int);
where Date is a class designed by me.
Can you give us more details about what your code is supposed to do?
I was making a Date Calculator.
The function will Be going through the values returned by function, checking it with the int value returned and then give suitable output.
I haven't entirely coded the functions yet, but I have them planned out before me.
To be honest, I still have no idea what the point is. What would be the point of passing a function rather than just the return value of a function?
Well yes it can be done that way!
Can't Imagine why didn't this come to me.
Probably reading up too much of function pointers doesn't help me!
Thanks...
Topic archived. No new replies allowed.