The following code is working!
function and function pointer are defined
I defined two probe function:
mysin1 and mysin2
both works with myfunc with in first argument
but I dont't understand,
because mysin2 wait for a function_pointer not a function
#include <math.h>
#include <iostream>
using namespace std;
typedef double func(double v);
typedef func *func_pointer;
double myfunc(double x)
{
return x*x;
}
double mysin1(func infunc, double x)
{
return sin(infunc(x));
}
double mysin2(func_pointer inpointer, double x)
{
return sin((*inpointer)(x));
}
int main()
{
func newf;
func_pointer newfp;
cout << mysin1(myfunc,2.) << ", " << sin(4.) << ", " << mysin2(myfunc,2.) << endl;
return 0;
}
result:
-0.765802, -0.765802,-0.765802