class CTelnetConnect
{
public:
CTelnetConnect();
virtual ~CTelnetConnect();
public:    typedef BOOL (CTelnetConnect::*pSetBoardProductInfo)(CString BdId, const E_BOARD_PRODINFO& board);
    pSetBoardProductInfo m_pSetBoardProductFunc;public:
  
    BOOL    InstallFunc(CString csver);
    BOOL    SetBoardProductInfo(CString BdId, const E_BOARD_PRODINFO& board);    ...
    ...
}BOOL CTelnetConnect::InstallFunc(CString csver)
{
  ...
   m_pSetBoardProductFunc = &CTelnetConnect::SetBoardProductInfo;
}void CInfoForm::OnButtonYyong() 
{
  if (((CMainFrame*)AfxGetMainWnd())->m_pTelnetConnect->m_pSetBoardProductFunc != NULL)
        {
     if((((CMainFrame*)AfxGetMainWnd())->m_pTelnetConnect->*m_pSetBoardProductFunc)(it->GetName(), pro)) //m_pSetBoardProductFunc怎么不认识????
     {
             ...
         }
}按语法来说应该是对的
但现在VC6.0 报 
error C2065: 'm_pSetBoardProductFunc' : undeclared identifier
error C2297: '->*' : illegal, right operand has type 'int'

解决方案 »

  1.   

    if((((CMainFrame*)AfxGetMainWnd())->m_pTelnetConnect->*m_pSetBoardProductFunc)(it->GetName(), pro)) 拼写错误,括号对不上
      

  2.   

    现简化为如下程序
    #include <iostream.h>class alpha
    {
    int data;
    public:
    alpha(int x) { data = x; }
    int show() { cout << data << endl; return 1;}
    int (alpha::*ifunc)();
    };void main()
    {
    alpha* a = new alpha(123);
    a->ifunc = &alpha::show; (a->*ifunc)();
    }error C2065: 'ifunc' : undeclared identifier
    error C2297: '->*' : illegal, right operand has type 'int'
      

  3.   

    typedef int (alpha::*ifunc)();
      

  4.   

    是报的:'m_pSetBoardProductFunc' : undeclared identifier
    没有声明注意:
    BOOL CTelnetConnect::InstallFunc(CString csver)
      m_pSetBoardProductFunc = &CTelnetConnect::SetBoardProductInfo;void CInfoForm::OnButtonYyong() 
      if((((CMainFrame*)AfxGetMainWnd())->m_pTelnetConnect->*m_pSetBoardProductFunc)(it->GetName(), pro)) //m_pSetBoardProductFunc怎么不认
    这是在两个不同的类中!!!!!!!!!!!
    一个是CTelnetConnect
    一个是CInfoForm
    不是全局变量,兄弟~!!!!!!!!!!!!!!!!!!!!!!呵
      

  5.   

    自己解决了 (a->*ifunc)();改为 (a->*(a->ifunc))();