class CMySocket;
class CTalk1Dlg : public CDialog
{
// Construction
public:
CTalk1Dlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CTalk1Dlg)
enum { IDD = IDD_TALK1_DIALOG };
CListBox m_listSent;
CListBox m_listReceived;
CComboBox m_cmbType;
CButton m_btnConnect;
CString m_strMsg;
CString m_strServName;
int m_nServPort;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTalk1Dlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CTalk1Dlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSelchangeComboType();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
CMySocket m_pListenSocket;
CMySocket m_sConnectSocket;
};
最后两句的错误提示是:
f:\1\talk1\talk1dlg.h(55) : error C2079: 'm_pListenSocket' uses undefined class 'CMySocket',上面不是已经定义了么?请指点。
6 个解决方案
#1
把 class CMySocket;去掉
#2
在“class CTalkDlg”前添加
#include "MySocket.h"
#include "MySocket.h"
#3
只有你定义的成员变量是对象指针时,可以用你的方法申明“class CTalkDlg”,并且要在实现CPP中INCLUDE该类定义的头文件,像你这样定义对象实体不能这么申明类,只能包含该类的定义头文件。
#4
把 class CMySocket;去掉,类还没生成不能用
#5
忘了说,是这儿的,去掉CMySocket
CMySocket m_pListenSocket;
CMySocket m_sConnectSocket;
CMySocket m_pListenSocket;
CMySocket m_sConnectSocket;
#6
谢谢各位。
如果去掉class CMySocket,就多了4个错误,提示是:
f:\1\talk1\talk1dlg.h(55) : error C2146: syntax error : missing ';' before identifier 'm_pListenSocket'
f:\1\talk1\talk1dlg.h(55) : error C2501: 'CMySocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(55) : error C2501: 'm_pListenSocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(56) : error C2146: syntax error : missing ';' before identifier 'm_sConnectSocket'
f:\1\talk1\talk1dlg.h(56) : error C2501: 'CMySocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(56) : error C2501: 'm_sConnectSocket' : missing storage-class or type specifiers
去掉CMySocket m_pListenSocket;前面的CMySocket会出现错误更多,
quanch(Lurker)提示的很有道理,但去掉也不行,真不知道问题出在那里。
如果去掉class CMySocket,就多了4个错误,提示是:
f:\1\talk1\talk1dlg.h(55) : error C2146: syntax error : missing ';' before identifier 'm_pListenSocket'
f:\1\talk1\talk1dlg.h(55) : error C2501: 'CMySocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(55) : error C2501: 'm_pListenSocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(56) : error C2146: syntax error : missing ';' before identifier 'm_sConnectSocket'
f:\1\talk1\talk1dlg.h(56) : error C2501: 'CMySocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(56) : error C2501: 'm_sConnectSocket' : missing storage-class or type specifiers
去掉CMySocket m_pListenSocket;前面的CMySocket会出现错误更多,
quanch(Lurker)提示的很有道理,但去掉也不行,真不知道问题出在那里。
#1
把 class CMySocket;去掉
#2
在“class CTalkDlg”前添加
#include "MySocket.h"
#include "MySocket.h"
#3
只有你定义的成员变量是对象指针时,可以用你的方法申明“class CTalkDlg”,并且要在实现CPP中INCLUDE该类定义的头文件,像你这样定义对象实体不能这么申明类,只能包含该类的定义头文件。
#4
把 class CMySocket;去掉,类还没生成不能用
#5
忘了说,是这儿的,去掉CMySocket
CMySocket m_pListenSocket;
CMySocket m_sConnectSocket;
CMySocket m_pListenSocket;
CMySocket m_sConnectSocket;
#6
谢谢各位。
如果去掉class CMySocket,就多了4个错误,提示是:
f:\1\talk1\talk1dlg.h(55) : error C2146: syntax error : missing ';' before identifier 'm_pListenSocket'
f:\1\talk1\talk1dlg.h(55) : error C2501: 'CMySocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(55) : error C2501: 'm_pListenSocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(56) : error C2146: syntax error : missing ';' before identifier 'm_sConnectSocket'
f:\1\talk1\talk1dlg.h(56) : error C2501: 'CMySocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(56) : error C2501: 'm_sConnectSocket' : missing storage-class or type specifiers
去掉CMySocket m_pListenSocket;前面的CMySocket会出现错误更多,
quanch(Lurker)提示的很有道理,但去掉也不行,真不知道问题出在那里。
如果去掉class CMySocket,就多了4个错误,提示是:
f:\1\talk1\talk1dlg.h(55) : error C2146: syntax error : missing ';' before identifier 'm_pListenSocket'
f:\1\talk1\talk1dlg.h(55) : error C2501: 'CMySocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(55) : error C2501: 'm_pListenSocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(56) : error C2146: syntax error : missing ';' before identifier 'm_sConnectSocket'
f:\1\talk1\talk1dlg.h(56) : error C2501: 'CMySocket' : missing storage-class or type specifiers
f:\1\talk1\talk1dlg.h(56) : error C2501: 'm_sConnectSocket' : missing storage-class or type specifiers
去掉CMySocket m_pListenSocket;前面的CMySocket会出现错误更多,
quanch(Lurker)提示的很有道理,但去掉也不行,真不知道问题出在那里。