我现在是想写个回调函数,过程是这样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这应该怎么办?

解决方案 »

  1.   

    extern Enter_Menu(void (WINAPI* ShowMenu)(int nIndex, int nLevel)) 这样呢
      

  2.   

    ShowCIMenu是CCIMenuDialog的成员函数,这样调用编译不能通过的。定义全局的CCIMenuDialog:
    CCIMenuDialog* pdlg = NULL;
    在合适地方赋值。将ShowCIMenu修改为全局的:
    void ShowCIMenu(int nIndex, int nLevel)
    {
      //使用pdlg指针操作 
      

  3.   

    我的void CCIMenuDialog::ShowCIMenu(int nIndex, int nLevel) 
    看了一下是_thiscall 调用类型的,这样还是不行哦
      

  4.   

    void ShowCIMenu(int nIndex, int nLevel) 应该是函数指针, 所以只能这样定义:
    void _stdcall ShowCIMenu(int nIndex, int nLevel); 全局的,而至于要用到CCIMenuDialog,楼主自己定义 static CCIMenuDialog* m_pCIMenuDialog ;