Q
QH Hong
Hi, I have several classes and several members.
class c1, c2, c3,...
member of class c1 is m11, m12,...
member of class c2 is m21, m22,...
Each member takes one argument (double type) and returns
double value.
I have a function which takes the function name and
do some calcuations and return the solution of the function.
double getsolution(memberpointer f, double x)
{
double y0 = f(x);
.... do some calculation
return yn;
}
I need
double y11 = getsolution(c1::m11, x1);
double y12 = getsolution(c1::m12, x2);
..
double y21 = getsolution(c2::m21, x1);
double y22 = getsolution(c2::m22, x2);
....
Is it possible to code like above?
How to define "memberpointer" at the definition
of getsolution?
class c1, c2, c3,...
member of class c1 is m11, m12,...
member of class c2 is m21, m22,...
Each member takes one argument (double type) and returns
double value.
I have a function which takes the function name and
do some calcuations and return the solution of the function.
double getsolution(memberpointer f, double x)
{
double y0 = f(x);
.... do some calculation
return yn;
}
I need
double y11 = getsolution(c1::m11, x1);
double y12 = getsolution(c1::m12, x2);
..
double y21 = getsolution(c2::m21, x1);
double y22 = getsolution(c2::m22, x2);
....
Is it possible to code like above?
How to define "memberpointer" at the definition
of getsolution?