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'
{
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'
#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'
没有声明注意:
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
不是全局变量,兄弟~!!!!!!!!!!!!!!!!!!!!!!呵