danielsbrewer
April 15th, 2003, 05:43 AM
Hi there. I was wondering if you could help me to solve my problem or avoid it all together.
I have a class that requires a pointer to a function in its constructor:
Simplexer::Simplexer( double min_func(vector<double>&),
const double tolerance)
And the class performs various algorithms. And this works fine if I pass a function pointer not in a class. The problem occurs when I want to pass it a class function, something like this:
Model model_1(rk,equation);
Simplexer yoyo(model_1.least_squares,1e-8);
cout << yoyo.go() << endl;
And this doesn't work at all. My latest attempt is to do this:
Simplexer yoyo(&(model_1.least_squares),1e-8);
But the error I get is:
src/p53.cc:61: no matching function for call to `Simplexer::Simplexer( double (Model::*)(std::valarray<double>),
double)'
(From gcc).
Any ideas? I know function pointers are a bit dodgy anyhow, so is there a way to get round it?
Thanks
I have a class that requires a pointer to a function in its constructor:
Simplexer::Simplexer( double min_func(vector<double>&),
const double tolerance)
And the class performs various algorithms. And this works fine if I pass a function pointer not in a class. The problem occurs when I want to pass it a class function, something like this:
Model model_1(rk,equation);
Simplexer yoyo(model_1.least_squares,1e-8);
cout << yoyo.go() << endl;
And this doesn't work at all. My latest attempt is to do this:
Simplexer yoyo(&(model_1.least_squares),1e-8);
But the error I get is:
src/p53.cc:61: no matching function for call to `Simplexer::Simplexer( double (Model::*)(std::valarray<double>),
double)'
(From gcc).
Any ideas? I know function pointers are a bit dodgy anyhow, so is there a way to get round it?
Thanks