I wish to write a function, which uses the return value of a double
function but/and I want to choose this double function during the function call. My idea is:
#include <iostream>
double linea(double a, double b, double x);
double parabola(double a, double b, double c, double x);
void konjgrad(double (*function)(void** params), void** params);
double linea(double a, double b, double x){
return a*x+b;
}
double parabola(double a, double b, double c, double x){
return a*x*x+b*x+c;
}
void konjgrad(double (*function)(void** params), void** params){
double d;
d=function(params);
std::cout<<d<<std::endl;
}
int main(){
konjgrad(linea(1.6,5.1,2.6));
konjgrad(parabola(2.4,3.1,4,2.6));
return 0;
}
But I stuck in the maze of the pointers. Has anyone an idea, how to solve the problem?