|
![]() | 作者: ejdm [ejdm]
![]() |
登录 |
创建了一个名为CMySocket的CAsyncSocket类,一个名为CTalkDlg的CDialog类。 在CMySocket中建立类型为CTalkDlg*的私有成员变量m_pDlg,在CTalkDlg中建立二个类型为CMySocket的私有成员变量m_ConnectSocket和m_ListenSocket。 在CMySocket中建立一个成员函数,在CTalkDlg启动时调用,将m_pDlg指向当前启动的对话框。具体代码如下: // MySocket.h: interface for the CMySocket class. class CMySocket : public CAsyncSocket { public: void SetParent(CTalkDlg* pDlg); CMySocket(); virtual ~CMySocket(); private: CTalkDlg* m_pDlg; }; // MySocket.cpp: implementation of the CMySocket class. // #include "stdafx.h" #include "Talk.h" #include "TalkDlg.h" #include "MySocket.h" void CMySocket::SetParent(CTalkDlg *pDlg) { m_pDlg=pDlg; } // TalkDlg.h : header file // #include "MySocket.h" // Added by ClassView private: CMySocket m_ListenSocket; CMySocket m_ConnectSocket; // TalkDlg.cpp : implementation file // #include "stdafx.h" #include "Talk.h" #include "MySocket.h" #include "TalkDlg.h" BOOL CTalkDlg::OnInitDialog() { m_Listensocket.SetParent(this); m_ConnectSocket.SetParent(this); } 编译时出错显示如下: error C2146: syntax error : missing ';' before identifier 'm_ListenSocket' error C2501: 'CMySocket' : missing storage-class or type specifiers error C2501: 'm_ListenSocket' : missing storage-class or type specifiers error C2146: syntax error : missing ';' before identifier 'm_ConnectSocket' error C2501: 'CMySocket' : missing storage-class or type specifiers error C2501: 'm_ConnectSocket' : missing storage-class or type specifiers 谢谢各位大哥帮我看看,是不是#include写得不对啊,我实在搞不懂啊。 |
地主 发表时间: 09/03 15:13 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号