我做的是一个单文档应用程序!
在VIEW 类里面有个这个函数,是自动生成的代码!
CTickets_SellDoc* GetDocument();
这个定义在类的头文件里面,也就是CVIEW里面,
开始没问题,后来我在VIEW 里面添加了一个成员CArray<CServerSock*,CServerSock*>;之后,而且还包含了头文件,但是他报错说:error C2065: 'CServerSock' : undeclared identifier这个我明明已经将其头文件包含进来了,不知道为什么????然后就报错了很多!
error C2059: syntax error : '>'
我添加的代码如下:
#include "Tickets_SellDoc.h"
#include "ServerSock.h"
#include <afxtempl.h>
class CTickets_SellView : public CFormView
{
protected: // create from serialization only
CTickets_SellView();
DECLARE_DYNCREATE(CTickets_SellView)
public:
//{{AFX_DATA(CTickets_SellView)
enum { IDD = IDD_TICKETS_SELL_FORM };
CListCtrl m_nList;
CString m_nNum;
CString m_nDesStop;
CString m_nSrcStop;
int m_nTNum;//票数
int m_nPrice;
//}}AFX_DATA// Attributes
public:
CTickets_SellDoc* GetDocument();
    void OnBtnSetup();
CArray<CServerSock,CServerSock*>;
// CServerSock  Sock;

解决方案 »

  1.   

    晕,你的变量怎么定义的:CArray <CServerSock,CServerSock*>       xxxxxx; 
    ====>
    CArray <CServerSock,CServerSock*> m_Array;
      

  2.   

    CArray<CServerSock *,CServerSock*> DataSock;
    不好意思我写错了。就是报错!
      

  3.   

    error C2065: 'CServerSock' : undeclared identifier
    d:\program\tickets_sell\tickets_sellview.h(21) : error C2059: syntax error : ','
    d:\program\tickets_sell\tickets_sellview.h(21) : error C2059: syntax error : '>'
    d:\program\tickets_sell\tickets_sellview.h(25) : error C2143: syntax error : missing ';' before '{'
    d:\program\tickets_sell\tickets_sellview.h(52) : error C2065: 'pInfo' : undeclared identifier
    d:\program\tickets_sell\tickets_sellview.h(52) : error C2275: 'CPrintInfo' : illegal use of this type as an expression
            d:\microsoft visual studio\vc98\mfc\include\afxext.h(1026) : see declaration of 'CPrintInfo'
    d:\program\tickets_sell\tickets_sellview.h(52) : error C2143: syntax error : missing ',' before ')'
    d:\program\tickets_sell\tickets_sellview.h(53) : error C2275: 'CPrintInfo' : illegal use of this type as an expression
            d:\microsoft visual studio\vc98\mfc\include\afxext.h(1026) : see declaration of 'CPrintInfo'
    d:\program\tickets_sell\tickets_sellview.h(53) : error C2143: syntax error : missing ',' before ')'
    d:\program\tickets_sell\tickets_sellview.h(54) : error C2275: 'CPrintInfo' : illegal use of this type as an expression
            d:\microsoft visual studio\vc98\mfc\include\afxext.h(1026) : see declaration of 'CPrintInfo'
    d:\program\tickets_sell\tickets_sellview.h(54) : error C2143: syntax error : missing ',' before ')'
    d:\program\tickets_sell\tickets_sellview.h(77) : error C2065: 'pResult' : undeclared identifier
    d:\program\tickets_sell\tickets_sellview.h(77) : error C2275: 'LRESULT' : illegal use of this type as an expression
            d:\microsoft visual studio\vc98\include\windef.h(172) : see declaration of 'LRESULT'
    d:\program\tickets_sell\tickets_sellview.h(77) : error C2143: syntax error : missing ',' before ')'
    d:\program\tickets_sell\tickets_sellview.h(83) : error C2143: syntax error : missing ';' before '}'
    d:\program\tickets_sell\serversock.h(16) : error C2143: syntax error : missing ';' before '{'
    d:\program\tickets_sell\serversock.h(25) : error C2143: syntax error : missing ';' before '}'
    d:\program\tickets_sell\serversock.h(28) : error C2143: syntax error : missing ';' before '{'
    d:\program\tickets_sell\serversock.h(59) : error C2143: syntax error : missing ';' before '}'
    d:\program\tickets_sell\mainfrm.h(13) : error C2143: syntax error : missing ';' before '{'
    d:\program\tickets_sell\mainfrm.h(51) : error C2143: syntax error : missing ';' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(19) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(19) : error C2248: '_messageEntries' : cannot access private member declared in class 'CTickets_SellApp'
            d:\program\tickets_sell\tickets_sell.h(40) : see declaration of '_messageEntries'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(19) : error C2143: syntax error : missing ',' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(21) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(21) : error C2065: 'OnAppAbout' : undeclared identifier
    D:\program\Tickets_Sell\Tickets_Sell.cpp(21) : error C2440: 'type cast' : cannot convert from 'int *' to 'void (__thiscall CCmdTarget::*)(void)'
            There is no context in which this conversion is possible
    D:\program\Tickets_Sell\Tickets_Sell.cpp(21) : error C2143: syntax error : missing ',' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(26) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(26) : error C2248: 'OnFileNew' : cannot access protected member declared in class 'CWinApp'
            d:\microsoft visual studio\vc98\mfc\include\afxwin.h(4166) : see declaration of 'OnFileNew'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(26) : error C2143: syntax error : missing ',' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(27) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(27) : error C2248: 'OnFileOpen' : cannot access protected member declared in class 'CWinApp'
            d:\microsoft visual studio\vc98\mfc\include\afxwin.h(4167) : see declaration of 'OnFileOpen'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(27) : error C2143: syntax error : missing ',' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(29) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(29) : error C2248: 'OnFilePrintSetup' : cannot access protected member declared in class 'CWinApp'
            d:\microsoft visual studio\vc98\mfc\include\afxwin.h(4170) : see declaration of 'OnFilePrintSetup'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(29) : error C2143: syntax error : missing ',' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(30) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(30) : error C2143: syntax error : missing ',' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(36) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(39) : error C2143: syntax error : missing ';' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(51) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(79) : error C2653: 'CMainFrame' : is not a class or namespace name
    D:\program\Tickets_Sell\Tickets_Sell.cpp(79) : error C2065: 'classCMainFrame' : undeclared identifier
    D:\program\Tickets_Sell\Tickets_Sell.cpp(80) : error C2027: use of undefined type 'CTickets_SellView'
            d:\program\tickets_sell\tickets_sellview.h(16) : see declaration of 'CTickets_SellView'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(80) : error C2143: syntax error : missing ',' before ')'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(112) : error C2143: syntax error : missing ';' before '}'
    _Sell.cpp(163) : error C2143: syntax error : missing ';' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(165) : error C2653: 'CAboutDlg' : is 
    D:\program\Tickets_Sell\Tickets_Sell.cpp(171) : error C2653: 'CAboutDlg' : is not a class or namespace name
    D:\program\Tickets_Sell\Tickets_Sell.cpp(172) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(176) : error C2143: syntax error : missing ';' before '}'
    C2248: '_messageEntries' : cannot access private member declared in class 'CFormView'
            d:\microsoft visual studio\vc98\mfc\include\afxext.h(774) : see declaration of '_messageEntries'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(178) : error C2143: syntax error : missing ',' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(178) : error C2653: 'CAboutDlg' : is not a class or namespace name
    D:\program\Tickets_Sell\Tickets_Sell.cpp(182) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(182) : error C2143: syntax error : missing ',' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(186) : error C2143: syntax error : missing ';' before '{'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(189) : error C2143: syntax error : missing ';' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(194) : error C2143: syntax error : missing ';' before '}'
    D:\program\Tickets_Sell\Tickets_Sell.cpp(194) : fatal error C1001: INTERNAL COMPILER ERROR
            (compiler file 'Y?, line 1) 
             Please choose the Technical Support command on the Visual C++ 
             Help menu, or open the Technical Support help file for more information
    Generating Code...
    Compiling...
    Tickets_SellView.cpp
    Generating Code...
    Error executing cl.exe.
    Creating browse info file...
    BSCMAKE: error BK1506 : cannot open file '.\Debug\MainFrm.sbr': No such file or directory
      

  4.   

    若把CArray <CServerSock *,CServerSock*> DataSock; 定义在类的实现部分就没问题!郁闷!怎么回事啊 ??
      

  5.   

    建议你是XXXView.h里面不要包含Serversock.h文件,直接用// Forward declare (向前声明)
    class CServerSock;CArray<CServerSock*,CServerSock*> DataSock;
    然后在XXXView.cpp里面包含它:
    #include "Serversock.h"
    #include "XXXView.h"
      

  6.   

    头文件包含顺序问题。在这里用前置声明:
    class CServerSock;
    即可。
      

  7.   

    #include  <afxtempl.h> 放到stdafx.h里面。