在头文件中定义如下:
void (*pOpFun[7])(CDC*);
void DrawUnit(CDC* pDC);在cpp文件中如下赋值:
pOpFun[0] = DrawUnit;
结果出现编译错误:
cannot convert from 'void (__thiscall CST_CurveCtrl::*)(class CDC *)' to 'void (__cdecl *)(class CDC *)改变DrawUnit的申明如下:
static void DrawUnit(CDC* pDC);
可以解决问题,但我不想这么做,请问还有什么办法?
void (*pOpFun[7])(CDC*);
void DrawUnit(CDC* pDC);在cpp文件中如下赋值:
pOpFun[0] = DrawUnit;
结果出现编译错误:
cannot convert from 'void (__thiscall CST_CurveCtrl::*)(class CDC *)' to 'void (__cdecl *)(class CDC *)改变DrawUnit的申明如下:
static void DrawUnit(CDC* pDC);
可以解决问题,但我不想这么做,请问还有什么办法?
void (CST_CurveCtrl::*pOpFun[7])(CDC*);
pOpFun[0] = DrawUnit;
(*pOpFun[i])(pdc);但做函数调用的时候却出现下面的编译错误:
'*' : illegal on operands of type 'void (__thiscall CST_CurveCtrl::*)(class CDC *)'
term does not evaluate to a function
若这样调用pOpFun[i](pdc);则错误如下:
term does not evaluate to a function
真的解决不了吗?很急啊,老板在催了!
直接把定义放在使用函数的上面.当然也不要有CST_CurveCtrl::不正规