有可能做这样的事情吗?不使用静态函数或chordL
创建power
. 我真的不明白该怎么做,这不可能吗?
class power {
double b;
public:
void set(double par){b=par}
double fun(double arg){
return b*pow(arg,2);
}
double execute(double par1, double par2);
};
double chordL(power::*fm, double p1, double p2){ // it's not a member function
return sqrt(pow(fm(p1)-fm(p2),2)+pow(p1-p2,2)); // clearly doesn't work!
}
double power::execute(double par1, double par2){ // it's a member function
double (power::*g)(double);
g=&power::fun;
return chordL(g,par1,par2);
}