Pointer to a C++ class member function as a global function's parameter?
- by marcin1400
I have got a problem with calling a global function, which takes a pointer to a function as a parameter.
Here is the declaration of the global function:
int lmdif ( minpack_func_mn fcn, void *p, int m, int n, double *x, double *fvec, double ftol)
The "minpack_func_mn" symbol is a typedef for a pointer to a function, defined as:
typedef int (*minpack_func_mn)(void *p, int m, int n, const double *x, double *fvec, int iflag );
I want to call the "lmdif" function with a pointer to a function which is a member of a class I created, and here is the declaration of this class function:
int LT_Calibrator::fcn(void *p, int m, int n, const double *x, double *fvec,int iflag)
I am calling a global function like this:
info=lmdif(<_Calibrator::fcn, 0, m, n, x, fvec, ftol)
Unfortunately, I get a compiler error, which says:
"error C2664: 'lmdif' : cannot convert parameter 1 from 'int (__thiscall LT_Calibrator::* )(void *,int,int,const double *,double *,int)' to 'minpack_func_mn'
1 There is no context in which this conversion is possible"
Is there any way to solve that problem?