单文档中,在mainframe定义view类的对象或者指针,就会出现'GetDocument' : missing storage-class or type specifiers的错误。大概是因为DOC类还不存在,而view要调用指向doc类的指针。因此出错,请问要如何解决呢?

解决方案 »

  1.   

    在mainframe中创建view类的对象
    http://topic.csdn.net/u/20110323/18/aec3bb7c-f7a8-41a4-8e10-f013ac26f1b6.html 一楼
      

  2.   

    在mainframe中写了CMainFrame *pMain = (CMainFrame *) AfxGetApp()->m_pMainWnd;
                    CMyView *pView=(CMyView *)pMain->GetActiveView();
    并在mainframe的cpp文件中包含了MyView的头文件,但还是同样在View中出现调用DOC的错误。
    public:
    CMyDoc* GetDocument();//这里出现错误
      

  3.   

    GetDoucment()是视图的成员函数,
    在CMainFrame中这样就可以取到文档类:
    CMyView *pView=(CMyView *)GetActiveView();
    CMyDocument *pDoc = (CMyDocument *)pView->GetDocument();