Reputation: 1
I am having some problems with my code.
I have a class:
class SingleNeuron {
public:
double hh_function (double t , double u);
double nn_function (double t , double u);
double zz_function (double t , double u);
double VV_function (double t , double u);
void calculating_next_step( double t0, double dt ) {
hh=rk4 ( t0, hh, dt, hh_function );
nn=rk4 ( t0, nn, dt, nn_function );
zz=rk4 ( t0, zz, dt, zz_function );
VV=rk4 ( t0, zz, dt, VV_function );
}
};
/*the rk4 is a function of someone else:*/
double rk4 ( double t0, double u0, double dt, double f ( double t, double u ) );
I'm getting the problem in hh, nn , zz ,VV:
error C3867: 'SingleNeuron::hh_function': function call missing argument list;
use '&SingleNeuron::hh_function' to create a pointer to member
I tried to change it to &SingleNeuron::hh_function and the problem is:
error C2664: 'rk4' : cannot convert parameter 4 from
'double (__thiscall SingleNeuron::* )(double,double)'
to 'double (__cdecl *)(double,double)'
1> There is no context in which this conversion is possible
Upvotes: 0
Views: 126
Reputation: 300
You can not pass a member function as a function as a function pointer, since a member function is meaningless without an instance.
If your hh_function only depends on its parameters. You can declare it as a static member function. In this way, you can pass it as a normal function pointer.
Upvotes: 1