我从CListView继承出来的类,编译出错:error C2504: 'CListView' : base class undefined
error C2440: 'return' : cannot convert from 'class CSpeechListView *' to 'class CObject *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
 error C2653: 'CListView' : is not a class or namespace name
 error C2065: 'classCListView' : undeclared identifier
error C2653: 'CListView' : is not a class or namespace name
error C2653: 'CListView' : is not a class or namespace name
error C2653: 'CListView' : is not a class or namespace name
 error C2065: 'm_pDocument' : undeclared identifier
error C2227: left of '->IsKindOf' must point to class/struct/union
我是单文档,加了Doc头文件;DECLARE_DYNCREATE(CSpeechListView);
MPLEMENT_DYNCREATE(CSpeechListView, CListView);错误在这里

解决方案 »

  1.   

    这是在CPP文件里出错的地方
    IMPLEMENT_DYNCREATE(CSpeechListView, CListView)CSpeechListView::CSpeechListView()
    {
    }CSpeechListView::~CSpeechListView()
    {
    }
    BEGIN_MESSAGE_MAP(CSpeechListView, CListView)
    //{{AFX_MSG_MAP(CSpeechListView)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CSpeechListView drawingvoid CSpeechListView::OnDraw(CDC* pDC)
    {
    CDocument* pDoc = GetDocument();
    // CListCtrl& refCtrl = GetListCtrl();
    // refCtrl.InsertItem(0, "Item!");
    }/////////////////////////////////////////////////////////////////////////////
    // CSpeechListView diagnostics#ifdef _DEBUG
    void CSpeechListView::AssertValid() const
    {
    CListView::AssertValid();
    }void CSpeechListView::Dump(CDumpContext& dc) const
    {
    CListView::Dump(dc);
    }
    #endif //_DEBUG
      

  2.   

    这是头文件class CSpeechListView : public CListView
    {
    protected:
    CSpeechListView();     // protected constructor used by dynamic creation
    DECLARE_DYNCREATE(CSpeechListView)//出错
      

  3.   

    在类的头文件或stdafx.h中加入:#include <afxcview.h>
      

  4.   

    这是在CPP文件
    IMPLEMENT_DYNCREATE(CSpeechListView, CListView)//出错CSpeechListView::CSpeechListView()
    {
    }CSpeechListView::~CSpeechListView()
    {
    }
    BEGIN_MESSAGE_MAP(CSpeechListView, CListView)
    //{{AFX_MSG_MAP(CSpeechListView)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CSpeechListView drawingvoid CSpeechListView::OnDraw(CDC* pDC)
    {
    CDocument* pDoc = GetDocument();
    // CListCtrl& refCtrl = GetListCtrl();
    // refCtrl.InsertItem(0, "Item!");
    }/////////////////////////////////////////////////////////////////////////////
    // CSpeechListView diagnostics#ifdef _DEBUG
    void CSpeechListView::AssertValid() const
    {
    CListView::AssertValid();//出错
    }void CSpeechListView::Dump(CDumpContext& dc) const
    {
    CListView::Dump(dc);//出错
    }
    #endif //_DEBUG
      

  5.   

    头文件未包含:#include <afxcview.h>