编程遇到一个小问题,本人不解,请教。。。。。。。。

chg2008 2005-03-12 05:05:01
编译时出现如下问题:(怎么会是语法错误?)
Compiling...
ClientSocket.cpp
e:\program files\microsoft visual studio\myprojects\e04\e04doc.h(38) : error C2061: syntax error : identifier 'CClientSocket'
e:\program files\microsoft visual studio\myprojects\e04\e04doc.h(61) : error C2061: syntax error : identifier 'CClientSocket'
e:\program files\microsoft visual studio\myprojects\e04\e04doc.h(62) : error C2061: syntax error : identifier 'CClientSocket'
e:\program files\microsoft visual studio\myprojects\e04\e04doc.h(64) : error C2143: syntax error : missing ';' before '*'
e:\program files\microsoft visual studio\myprojects\e04\e04doc.h(64) : error C2501: 'CClientSocket' : missing storage-class or type specifiers
e:\program files\microsoft visual studio\myprojects\e04\e04doc.h(64) : error C2501: 'm_clientSocket' : missing storage-class or type specifiers
执行 cl.exe 时出错.

出错的.h文件是这样的:

// E04Doc.h : interface of the CE04Doc class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_E04DOC_H__E4D66C75_DF8D_4316_B0DE_8C24C14DA330__INCLUDED_)
#define AFX_E04DOC_H__E4D66C75_DF8D_4316_B0DE_8C24C14DA330__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ListenSocket.h"
#include "ClientSocket.h"

#define MAX_BUFFER_SIZE 100

#define BASE_CHANNEL 2000

class CE04Doc : public CDocument
{
protected: // create from serialization only
CE04Doc();
DECLARE_DYNCREATE(CE04Doc)

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CE04Doc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
public:
void ReadMessage(CClientSocket* cSocket); //从客户套接字读取信息
void AcceptClient(); //从侦听套接字中接受客户连接的请求


// Implementation
public:
virtual ~CE04Doc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
//{{AFX_MSG(CE04Doc)
afx_msg void OnFileStart();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void SendMessage(CClientSocket* socket,char* buffer); //向客户套接字发送信息
void ShowMessage(CClientSocket* socket,char* buffer); //显示从客户套接字接受到的信息
CPtrList m_list;//客户套接字列表
CClientSocket *m_clientSocket;
CListenSocket *m_listenSocket;
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_E04DOC_H__E4D66C75_DF8D_4316_B0DE_8C24C14DA330__INCLUDED_)

其中CClientSocket,CListenSocket 是从CSocket继承过来的

...全文
95 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chg2008 2005-03-15
  • 打赏
  • 举报
回复
请教
chg2008 2005-03-14
  • 打赏
  • 举报
回复
呵呵
谢谢楼上的,加了这两句就行,但是我有个问题,不是已经把头文件包括进来,为什么还有声明一下类
chg2008 2005-03-13
  • 打赏
  • 举报
回复
问题依旧
nuaawenlin 2005-03-13
  • 打赏
  • 举报
回复
class CClientSocket;
class CListenSocket;
CClientSocket *m_clientSocket;
CListenSocket *m_listenSocket;
joysunstar 2005-03-12
  • 打赏
  • 举报
回复
CClientSocket未声明,加
class CClientSocket;在class xxxDoc前试试

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧