单文档程序,在C**View中加了CMyPicView*pMyPicView = NULL;
在他的构造函数中加了pMyPicView = this;
然后在C**Doc中加上了
BOOL CMyPicDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;

// TODO: Add your specialized creation code here
        extern CMyPicView*pMyPicView; if(pMyPicView) return pMyPicView->ShowPic(lpszPathName);

return TRUE;
}ShowPic()是C**View的函数
有错误
F:\2008-2009自己的程序\MyPic\MyPicDoc.cpp(92) : error C2143: syntax error : missing ';' before '*'
F:\2008-2009自己的程序\MyPic\MyPicDoc.cpp(92) : error C2065: 'pMyPicView' : undeclared identifier
F:\2008-2009自己的程序\MyPic\MyPicDoc.cpp(92) : error C2100: illegal indirection
F:\2008-2009自己的程序\MyPic\MyPicDoc.cpp(94) : error C2227: left of '->ShowPic' must point to class/struct/union
Error executing cl.exe.
怎么回事?

解决方案 »

  1.   

    extern CMyPicView*pMyPicView; 
    这个应该放在BOOL CMyPicDoc::OnOpenDocument(LPCTSTR lpszPathName) 上边,成为全局变量
      

  2.   

    单文档程序,在C**View中加了CMyPicView*pMyPicView = NULL; 
    在他的构造函数中加了pMyPicView =new CMPicView(); 
    然后在C**Doc中加上了 
    BOOL CMyPicDoc::OnOpenDocument(LPCTSTR lpszPathName) 

    if (!CDocument::OnOpenDocument(lpszPathName)) 
    return FALSE; // TODO: Add your specialized creation code here 
     if(pMyPicView) return pMyPicView->ShowPic(lpszPathName); return TRUE; 
      

  3.   


    正确还有就是添加一个头文件#include "MyPicView.h"
      

  4.   


    在C**View 的类声明前添加声明 class CMyPicView;如下:
    class CMyPicView;
    class C**View :public cview
    { CMyPicView *pMyPicView ;
    };在该类的实现文件(.cpp)添加#include "MyPicView.h"
      

  5.   

    extern CMyPicView*pMyPicView; //-----------------------87BOOL CMyPicDoc::OnOpenDocument(LPCTSTR lpszPathName) 
    {
    if (!CDocument::OnOpenDocument(lpszPathName))
    return FALSE;

    // TODO: Add your specialized creation code here
    if(pMyPicView) return pMyPicView->ShowPic(lpszPathName);//-------------------97

    return TRUE;
    }
    还是不行~~~
    F:\2008-2009自己的程序\MyPic\MyPicDoc.cpp(87) : error C2143: syntax error : missing ';' before '*'
    F:\2008-2009自己的程序\MyPic\MyPicDoc.cpp(87) : error C2501: 'pMyPicView' : missing storage-class or type specifiers
    F:\2008-2009自己的程序\MyPic\MyPicDoc.cpp(97) : error C2227: left of '->ShowPic' must point to class/struct/union
      

  6.   

    在DOC头文件上加class CMyPicView; 
      

  7.   

    class CMyPicView
    extern CMyPicView*pMyPicView; //-----------------------87 
    BOOL CMyPicDoc::OnOpenDocument(LPCTSTR lpszPathName) 

    if (!CDocument::OnOpenDocument(lpszPathName)) 
    return FALSE; // TODO: Add your specialized creation code here 
    if(pMyPicView) return pMyPicView->ShowPic(lpszPathName);//-------------------97 return TRUE; 
      

  8.   

    我把class CMyPicView; 加到了Doc头文件 依然不行
    F:\2008-2009自己的程序\MyPic\MyPicDoc.cpp(97) : error C2027: use of undefined type 'CMyPicView'
            f:\2008-2009自己的程序\mypic\mypicdoc.h(12) : see declaration of 'CMyPicView'
    F:\2008-2009自己的程序\MyPic\MyPicDoc.cpp(97) : error C2227: left of '->ShowPic' must point to class/struct/union
    Error executing cl.exe.