|
-
June 16th, 2010, 10:55 AM
#1
Problems with Member Function Addresses
Hello,
I am doing numerical work and am using the GSL (GNU scientific library) to help me with my endeavors. I recently had some code working procedurally, and then switched over to object oriented for the purposes of code reuse. The problem is I am having trouble using a library function that was working fine before.
GSL defines a data type or class called gsl_function. It has has two members, one which is a pointer to a function and one which is a general void pointer (for the purposes of taking in parameters). The function pointer has prototype given by
double (*function) (double x, void * params).
So you define a function f that returns a double and takes in a double and a void pointer, and then you write
gsl_function F;
F.function = &f;
I got this to work in a procedural setting. Now I am trying to do this in a class. My class has a member called myODE_dydx_ which has exactly the form I described for f. Then inside another member function called func, I have
gsl_function F;
F.function = &LensSolver::myODE_dydx_;
(LensSolver is the name of my class) When I put this in, I get the error:
error: cannot convert ‘double (LensSolver::*)(double, void*)’ to ‘double (*)(double, void*)’ in assignment.
However, when I leave out the "LensSolver::" I still get this error in addition to another one, which I googled and found out is related to how member functions are addressed. I don't have the faintest clue what its telling me, much less how to solve it. Any help? (Also, in a stroke of inspiration I tried &this->myOde_dydx_ which didn't work at all)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|