我现在是想写个回调函数,过程是这样Enter_Menu(void (*ShowMenu)(int nIndex, int nLevel)) //这是我要用来处理的函数
{
}另一个文件调用这个函数
extern Enter_Menu(void (*ShowMenu)(int nIndex, int nLevel));Enter_Menu(ShowCIMenu); //传入ShowCIMenu函数地址void CCIMenuDialog::ShowCIMenu(int nIndex, int nLevel)
{
}可现在会报这样的错误
error C2664: 'Enter_Menu' : cannot convert parameter 1 from 'void (int,int)' to 'void (__cdecl *)(int,int)'
None of the functions with this name in scope match the target type这应该怎么办?
{
}另一个文件调用这个函数
extern Enter_Menu(void (*ShowMenu)(int nIndex, int nLevel));Enter_Menu(ShowCIMenu); //传入ShowCIMenu函数地址void CCIMenuDialog::ShowCIMenu(int nIndex, int nLevel)
{
}可现在会报这样的错误
error C2664: 'Enter_Menu' : cannot convert parameter 1 from 'void (int,int)' to 'void (__cdecl *)(int,int)'
None of the functions with this name in scope match the target type这应该怎么办?
CCIMenuDialog* pdlg = NULL;
在合适地方赋值。将ShowCIMenu修改为全局的:
void ShowCIMenu(int nIndex, int nLevel)
{
//使用pdlg指针操作
}
看了一下是_thiscall 调用类型的,这样还是不行哦
void _stdcall ShowCIMenu(int nIndex, int nLevel); 全局的,而至于要用到CCIMenuDialog,楼主自己定义 static CCIMenuDialog* m_pCIMenuDialog ;