我用mfc 编写单文档程序,可以切分成3个窗口,每个窗口实现不同的功能,分别可以显示目录,做浏览器,字编辑,现在编译出错,有这样的提示:
d:\microsoft visual studio\msdev98\myprojects\myprog\myprogview.h(22) : error C2143: syntax error : missing ';' before '*'
d:\microsoft visual studio\msdev98\myprojects\myprog\myprogview.h(22) : error C2501: 'CMyProgDoc' : missing storage-class or type specifiers
d:\microsoft visual studio\msdev98\myprojects\myprog\myprogview.h(22) : error C2501: 'GetDocument' : missing storage-class or type specifiers
Generating Code...
源码:
  class CMyProgView : public CEditView
{
protected: // create from serialization only
CMyProgView();
DECLARE_DYNCREATE(CMyProgView)// Attributes
public:

CMyProgDoc* GetDocument();
// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyProgView)
public:
virtual void OnDraw(CDC* pDC);  // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL    源码好象不会有问题的 不知为何总是出错?

解决方案 »

  1.   

    CMyProgDoc* GetDocument();错误在这里
    你肯定在头文件里声明是有问题了,
    在"MyProgView.h"里包含"MyProgViewdoc.h"这个文件试试
      

  2.   

    在你的CMyProgView的头文件中,包含CMyProgDoc类的头文件就可以了对于新手,此类错误常见,以后就知道怎么解决了,呵呵
      

  3.   

    在class CMyProgView : public CEditView之前加上:class CMyProgDoc;
      

  4.   

    class CMyProgDoc
    class CMyProgView : public CEditView
    {
    protected: // create from serialization only
    CMyProgView();
    ........