error LNK2001: unresolved external symbol "public: class CAnalyserDoc * __thiscall CMySkyView::GetDocument(void)" (?GetDocument@CMySkyView@@QAEPAVCAnalyserDoc@@XZ)
我自己建了一个类
class CMySkyView : public CView在CMySkyView里面需要与其他对话框等通讯,所以使用了 CMySkyView::GetDocument   这样有什么错误?

解决方案 »

  1.   

    检查你那个GetDocument函数
    是不是不小心写到#ifdef _DEBUG
    #endif //_DEBUG里面去了
      

  2.   

    View类的h文件的类似下面的代码你是不是去掉了class CXXView : public CView
    {
     ...
    };#ifndef _DEBUG  // debug version in BView.cpp
    inline CXXXDoc* CBView::GetDocument()
       { return (CBDoc*)m_pDocument; }
    #endif
      

  3.   

    我的h文件#endif // _MSC_VER > 1000
    // MySkyView.h : header file
    //
    #include "SimuSet.h"
    #include <list>
    #include <vector>
    using namespace std;
    #include "AnalyserDoc.h"class Model;
    /////////////////////////////////////////////////////////////////////////////
    // CMySkyView view
    #define UM_PROGRESS WM_USER+1class CMySkyView : public CView
    {
    protected:
    CMySkyView();           // protected constructor used by dynamic creation
    DECLARE_DYNCREATE(CMySkyView)// Attributes
    public:
    //  CFCAnalyserDoc* GetDocument();
    public:// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CMySkyView)
    //}}AFX_VIRTUAL// Implementation
    protected:
    virtual ~CMySkyView();#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
    inline CFCAnalyserDoc* CMySkyView::GetDocument()
       { return (CFCAnalyserDoc*)m_pDocument; }
    #endif // Generated message map functions
    protected:
    //{{AFX_MSG(CMySkyView)
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };
    在 cpp里写了
    CAnalyserDoc* CMySkyView::GetDocument() // non-debug version is inline
    {
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAnalyserDoc)));
    return (CAnalyserDoc*)m_pDocument;
    }
      

  4.   

    看看头文件里面和源文件里面,实现了吧?
    是不是你头文件包含的问题?增加了#include "AnalyserDoc.h"不?
      

  5.   


    上面的是我主要的框架  
    另外我还自定义了一些函数
    在那些函数里用了   CAnalyserDoc * pDoc = GetDocument();
      

  6.   


    我在 MySkyView.h 里包含了 "AnalyserDoc.h" 的啊
    为了和其他的对话框视图啥的通讯 我在在CMySkyView的一些自定义函数里用了 CAnalyserDoc * pDoc = GetDocument()    这样对不?
      

  7.   


    我新建的这个 CMySkyView 类  本来是 没有 这个“CAnalyserDoc* GetDocument();”的   这个里面是这样的
    #ifndef _DEBUG  // debug version in BView.cpp
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
    #endif
      

  8.   


    #ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
    inline CFCAnalyserDoc* CMySkyView::GetDocument()
      { return (CFCAnalyserDoc*)m_pDocument; }
    #endif在 cpp里写了
    CAnalyserDoc* CMySkyView::GetDocument() // non-debug version is inline
    {
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAnalyserDoc)));
    return (CAnalyserDoc*)m_pDocument;
    }这样写的话DEBUG版本也编译不过吧,改成这样
    #ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
    #endifinline CFCAnalyserDoc* CMySkyView::GetDocument()
      { return (CFCAnalyserDoc*)m_pDocument; }
      

  9.   


    #ifndef _DEBUG  // debug version in SDIDemoView.cpp
    inline CSDIDemoDoc* CSDIDemoView::GetDocument()
       { return (CSDIDemoDoc*)m_pDocument; }
    #endif
      

  10.   

    是把中间的virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;去掉?

    inline CFCAnalyserDoc* CMySkyView::GetDocument()
      { return (CFCAnalyserDoc*)m_pDocument; } 
    写在
    #ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
    #endif
    外面也不行啊