What I like to do when dealing with pointers to functions is to make a typedef for them. Here is one for a function used with the BeginThread call in Windows :
typedef UINT( __stdcall * ThreadFunc )( PVOID );
It appears that library has one too called nlopt_func. In the documentation it shows the function has the prototype :
double f(unsigned n, const double* x, double* grad, void* f_data)
The problem is that is not a prototype for a method of your class. It is a standalone function. This means you have to pass a pointer to your object through the f_data parameter. You should implement it like this :
double MyFunction( unsigned n, const double *x, double *grad, void *pdata )
{
CNonlinearOptimization * pnlo = (CNonlinearOptimization *)pdata;
pnlo->myfunction( n, x, grad );
}
and you should remove my_constraint_data as an argument to your method, as shown in this snippet.
This same tactic should be used with mycontstraint1.