目前位置: VCer资源中心 >>> VCer论坛 >>> 技术问答

[本帖已阅读477次 分值2 回复0次] 张贴资源 发回信箱 控制面板

纯虚类的问题

提供者:zhaoxupear 张贴时间:2007-09-20 19:09:19.0 出处:vcer.net 作者:风中王子

纯虚类的问题(2007-09-20 19:09:19.0)


风中王子


        一个性格开朗的家伙,喜欢追逐风,跟它赛跑,永不认输!  
级别: VCer小兵
头衔: VCer会员

经验: 77
作品: 6
分会: 华北分会
注册: 2007-09-15 21:39:08.0
登录: 2007-11-23 18:27:28.0

...还是切分界面的问题,我改了几个错误,可有个错误是关于纯虚类的,改了半天都没改出来,各位大侠帮帮忙,谢了。

错误为:

D:\VC\MSDev98\MyProjects\dbvView\dbvView.cpp(92) : error C2259: ’CNewView’ : cannot instantiate abstract class due to following members:

        d:\vc\msdev98\myprojects\dbvview\mainfrm.h(66) : see declaration of ’CNewView’

其中dbvView.cpp中的内容为:

// dbvView.cpp : Defines the class behaviors for the application.

//

#include "stdafx.h"

#include "dbvView.h"

#include "dbvViewView.h"

#include "MainFrm.h"

#include "dbvViewDoc.h"

#include "LeftView.h"

//#include "Graphics.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CDbvViewApp

BEGIN_MESSAGE_MAP(CDbvViewApp, CWinApp)

    //{{AFX_MSG_MAP(CDbvViewApp)

    ON_COMMAND(ID_APP_ABOUT, OnAppAbout)

        // NOTE - the ClassWizard will add and remove mapping macros here.

        //    DO NOT EDIT what you see in these blocks of generated code!

    //}}AFX_MSG_MAP

    // Standard file based document commands

    ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)

    ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)

    // Standard print setup command

    ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CDbvViewApp construction

CDbvViewApp::CDbvViewApp()

{

    // TODO: add construction code here,

    // Place all significant initialization in InitInstance

}

/////////////////////////////////////////////////////////////////////////////

// The one and only CDbvViewApp object

CDbvViewApp theApp;

/////////////////////////////////////////////////////////////////////////////

// CDbvViewApp initialization

BOOL CDbvViewApp::InitInstance()

{

    AfxEnableControlContainer();

    // Standard initialization

    // If you are not using these features and wish to reduce the size

    //  of your final executable, you should remove from the following

    //  the specific initialization routines you do not need.

#ifdef _AFXDLL

    Enable3dControls();            // Call this when using MFC in a shared DLL

#else

    Enable3dControlsStatic();    // Call this when linking to MFC statically

#endif

    // Change the registry key under which our settings are stored.

    // TODO: You should modify this string to be something appropriate

    // such as the name of your company or organization.

    SetRegistryKey(_T("Local AppWizard-Generated Applications"));

    LoadStdProfileSettings();  // Load standard INI file options (including MRU)

    // Register the application’s document templates.  Document templates

    //  serve as the connection between documents, frame windows and views.

    CSingleDocTemplate* pDocTemplate;

    pDocTemplate = new CSingleDocTemplate(

        IDR_MAINFRAME,

        RUNTIME_CLASS(CDbvViewDoc),

        RUNTIME_CLASS(CMainFrame),      // main SDI frame window

        RUNTIME_CLASS(CLeftView));

    AddDocTemplate(pDocTemplate);

    // Parse command line for standard shell commands, DDE, file open

    CCommandLineInfo cmdInfo;

    ParseCommandLine(cmdInfo);

    // Dispatch commands specified on the command line

    if (!ProcessShellCommand(cmdInfo))

CView* pActiveView = ((CFrameWnd*)m_pMainWnd)->GetActiveView();

m_pOldView = pActiveView;

m_pNewView = (CView*) new CNewView;

CDocument* pCurrentDoc = ((CFrameWnd*)m_pMainWnd)->GetActiveDocument();

// 初始化一个CCreateContext对象来指向这个活动文档

// 利用这个环境(context),新视图在CView::OnCreate()中该视图被创建时。被加入到该文档。

CCreateContext newContext;

newContext.m_pNewViewClass = NULL;

newContext.m_pNewDocTemplate = NULL;

newContext.m_pLastView = NULL;

newContext.m_pCurrentFrame = NULL;

newContext.m_CurrentDoc = pCurrentDoc;

// 最初的活动视图的ID是AFX_IDW_PANE_FIRST,

// 对它加一使新增的视图工作在标准的文档/视图环境下

// 注意这一技巧不能用于切割视图图类CSplitterWnd的情况

UINT viewID = AFX_IDW_PANE_FIRST + 1;

CRect rect(0,0,0,0); // 将在后面重新设置大小

// 创建一个新视图,本例中该视图的生命周期与应用程序相同

// 应用程序关闭时会自动地清除视图对象

m_pNewView->Create(NULL, "AnyWindowName", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);

// 当一个文档模板创建一个视图,消息WM_INITIALUPDATE会被自动地发出,

// 但是本代码必须明确地发出这个消息(这个消息的作用就是让视图对象调用自己的OnInitialUpdate函数进行初始化)

m_pNewView->SendMessage(WM_INITIALUPDATE, 0, 0);

// 加入的新代码到这里结束

        return FALSE;

    // The one and only window has been initialized, so show and update it.

    m_pMainWnd->ShowWindow(SW_SHOW);

    m_pMainWnd->UpdateWindow();

    return TRUE;

}

/////////////////////////////////////////////////////////////////////////////

// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog

{

public:

    CAboutDlg();

// Dialog Data

    //{{AFX_DATA(CAboutDlg)

    enum { IDD = IDD_ABOUTBOX };

    //}}AFX_DATA

    // ClassWizard generated virtual function overrides

    //{{AFX_VIRTUAL(CAboutDlg)

    protected:

    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

    //}}AFX_VIRTUAL

// Implementation

protected:

    //{{AFX_MSG(CAboutDlg)

        // No message handlers

    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()

};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)

{

    //{{AFX_DATA_INIT(CAboutDlg)

    //}}AFX_DATA_INIT

}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)

{

    CDialog::DoDataExchange(pDX);

    //{{AFX_DATA_MAP(CAboutDlg)

    //}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)

    //{{AFX_MSG_MAP(CAboutDlg)

        // No message handlers

    //}}AFX_MSG_MAP

END_MESSAGE_MAP()

// App command to run the dialog

void CDbvViewApp::OnAppAbout()

{

    CAboutDlg aboutDlg;

    aboutDlg.DoModal();

}

/////////////////////////////////////////////////////////////////////////////

// CDbvViewApp message handlers

CNewView的定义为:(是在mainfrm.h中的)

// Overrides

class CNewView : public CView

{  };

CView* m_pOldView;

CView* m_pNewView;

CView* SwitchView();

CView* pActiveView;

请问应该怎么改啊?

注:转载文章需注明来源:VCer.net 文章地址:http://vcer.net/1190286559109.html

  如果你觉得VCer.net不错,而且你愿意为VCer.net捐赠一元钱,那么点击后面的捐赠按钮吧:) vcer.net捐赠

赵旭
[回复该贴] [加入个人书签]