C++ wrapping
linas@austin.ibm.com
linas@austin.ibm.com
Mon Apr 12 16:11:00 GMT 2004
On Fri, Apr 09, 2004 at 02:36:14PM -0700, eknecronzontas wrote:
>
> So is there a better way? I'd love to hear any
> ideas.
Sure. Pretend it was c not c++:
class GSLSolver
{
public:
virtual void declare_func_to_solve (double (*f)(double));
virtual double get_solution(void);
private:
double (*fs)(double);
};
void GSLSolver :: declare_func_to_solve (double (*f)(double))
{
fs = f;
}
double my_func (double x) { return x*x-x; }
main () {
GSLSolver mysolver;
mysolver.declare_func_to_solve (my_func);
printf ("the answer is %f\n", mysolver.get_solution());
}
--linas
More information about the Gsl-discuss
mailing list