编程遇到一个小问题,本人不解,请教。。。。。。。。
编译时出现如下问题:(怎么会是语法错误?)
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继承过来的