注册 登录
编程论坛 VC.NET论坛

为什么不能继承CView类

rxgmoral 发布于 2006-02-27 13:27, 1283 次点击

为什么不能继承CView类
写了一个CmView类并继承CView类

<<<<<<<<<<CmView.h>>>>>>>>>
#pragma once
class CmView : public CView
{
DECLARE_DYNCREATE(CmView)
protected:
CmView();
virtual ~CmView();
public:
virtual void OnDraw(CDC* pDC);
#ifdef _DEBUG
virtual void AssertValid() const;
#ifndef _WIN32_WCE
virtual void Dump(CDumpContext& dc) const;
#endif
#endif
};

<<<<<<<<<<<CmView.Cpp>>>>>>>>>>>
#include "stdafx.h"
#include "CmView.h"
IMPLEMENT_DYNCREATE(CmView, CView)
CmView::CmView()
{}
CmView::~CmView()
{}

void CmView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
}
#ifdef _DEBUG
void CmView::AssertValid() const
{
CView::AssertValid();
}

#ifndef _WIN32_WCE
void CmView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif
#endif //_DEBUG

现写了一个继承CmView类
<<<<<<<<<<LeftWnd.h>>>>>>>>>>
#pragma once
#include "CmView.h"
class LeftWnd : public CmView
{
DECLARE_DYNCREATE(LeftWnd)
protected:
LeftWnd();
virtual ~LeftWnd();
public:
virtual void OnDraw(CDC* pDC);
#ifdef _DEBUG
virtual void AssertValid() const;
#ifndef _WIN32_WCE
virtual void Dump(CDumpContext& dc) const;
#endif
#endif
};

<<<<<<<<<<<<<<<LeftWnd.Cpp>>>>>>>>>>>
#include "stdafx.h"
#include "Test.h"
#include "LeftWnd.h"

IMPLEMENT_DYNCREATE(LeftWnd, CmView)
LeftWnd::LeftWnd()
{
}

LeftWnd::~LeftWnd()
{
}
void LeftWnd::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
}
#ifdef _DEBUG
void LeftWnd::AssertValid() const
{
CmView::AssertValid();
}

#ifndef _WIN32_WCE
void LeftWnd::Dump(CDumpContext& dc) const
{
CmView::Dump(dc);
}
#endif
#endif //_DEBUG

编译没有报错,但是运行后报错,错那了

谢谢:)

1 回复
#2
冰镇柠檬汁儿2006-02-28 09:53
CView类是所有视图的基类,怎么会不能继承呢,你报什么错?
1