刚才那个问题我已经结贴;
但现在问题是:
class c1{
public:
c1(){};
~c1(){};
double simpsn(double eps,double (c1::*fun)(double)){double a=fun(eps);return a;};
double fZqmnx(double){return 0.;};
void zlk(void){simpsn(0.,&c1::fZqmnx);};//È¥µôÕâ¾äÊÇÄܹ»Í¨¹ý±àÒëµÄ¡£
};
int main(void)
{
c1 inst;
inst.simpsn(0., c1::fZqmnx);
return 0;
}
就是在simpsn中调用fun时,编译立刻出错,报告Call of nonfunction;
请问为什么?
问题出在你的调用方法上!
double simpsn(double eps,double (c1::*fun)(double)){
double a=(this->*fun)(eps);//成员函数的调用是这样的!
return a;
}
micropentium6(小笨)说得对,
另外:
inst.simpsn(0., c1::fZqmnx);
写成:inst.simpsn(0., &1::fZqmnx);
更符合标准,否则前一种写法在有的编译器上可能出错.