为什么不能继承CView类
<P>为什么不能继承CView类<BR>写了一个CmView类并继承CView类</P><P><<<<<<<<<<CmView.h>>>>>>>>><BR>#pragma once<BR>class CmView : public CView<BR>{<BR> DECLARE_DYNCREATE(CmView)<BR>protected:<BR> CmView(); <BR> virtual ~CmView();<BR>public:<BR> virtual void OnDraw(CDC* pDC); <BR>#ifdef _DEBUG<BR> virtual void AssertValid() const;<BR>#ifndef _WIN32_WCE<BR> virtual void Dump(CDumpContext& dc) const;<BR>#endif<BR>#endif<BR>};</P>
<P><<<<<<<<<<<CmView.Cpp>>>>>>>>>>><BR>#include "stdafx.h"<BR>#include "CmView.h"<BR>IMPLEMENT_DYNCREATE(CmView, CView)<BR>CmView::CmView()<BR>{}<BR>CmView::~CmView()<BR>{}</P>
<P>void CmView::OnDraw(CDC* pDC)<BR>{<BR> CDocument* pDoc = GetDocument();<BR>}<BR>#ifdef _DEBUG<BR>void CmView::AssertValid() const<BR>{<BR> CView::AssertValid();<BR>}</P>
<P>#ifndef _WIN32_WCE<BR>void CmView::Dump(CDumpContext& dc) const<BR>{<BR> CView::Dump(dc);<BR>}<BR>#endif<BR>#endif //_DEBUG</P>
<P>现写了一个继承CmView类<BR><<<<<<<<<<LeftWnd.h>>>>>>>>>><BR>#pragma once<BR>#include "CmView.h"<BR>class LeftWnd : public CmView<BR>{<BR> DECLARE_DYNCREATE(LeftWnd)<BR>protected:<BR> LeftWnd(); <BR> virtual ~LeftWnd();<BR>public:<BR> virtual void OnDraw(CDC* pDC); <BR>#ifdef _DEBUG<BR> virtual void AssertValid() const;<BR>#ifndef _WIN32_WCE<BR> virtual void Dump(CDumpContext& dc) const;<BR>#endif<BR>#endif<BR>};</P>
<P><<<<<<<<<<<<<<<LeftWnd.Cpp>>>>>>>>>>><BR>#include "stdafx.h"<BR>#include "Test.h"<BR>#include "LeftWnd.h"</P>
<P>IMPLEMENT_DYNCREATE(LeftWnd, CmView)<BR>LeftWnd::LeftWnd()<BR>{<BR>}</P>
<P>LeftWnd::~LeftWnd()<BR>{<BR>}<BR>void LeftWnd::OnDraw(CDC* pDC)<BR>{<BR> CDocument* pDoc = GetDocument();<BR>}<BR>#ifdef _DEBUG<BR>void LeftWnd::AssertValid() const<BR>{<BR> CmView::AssertValid();<BR>}</P>
<P>#ifndef _WIN32_WCE<BR>void LeftWnd::Dump(CDumpContext& dc) const<BR>{<BR> CmView::Dump(dc);<BR>}<BR>#endif<BR>#endif //_DEBUG</P>
<P>编译没有报错,但是运行后报错,错那了</P>
<P>谢谢:)<BR></P>
页:
[1]
