So.. what's the compilation error message? At what line?
I would probably try to pass in a function pointer instead, since "gset" is an array of function pointers, maybe try to define the "compute" function as:
double compute(double (*f)(double x), double i)
The rest can remain unchanged.
Also, as a matter of habit, you should avoid using a goto statement, because it is generally considered bad practice and off-putting for any programmer who might look at the code. Especially in this case, it is easy to avoid it with:
while(true) {
cout << "Input Please: ";
cin >> input;
cout << "Function Please: ";
cin >> function;
ans = compute(gset[function-1], input);
cout << ans;
};
Also notice how the indentation makes it clearer that this is a loop. Even if you use goto-statements, you should indent if you can.
mike_2000_17
21st Century Viking
3,135 posts since Jul 2010
Reputation Points: 2,050
Solved Threads: 625
Skill Endorsements: 41