Inheritance[候大大]

#include "stdafx.h"
#include <iostream>

using namespace std;

class CDocument
{
public:
	void OnFileOpen()
	{
		cout << "dialog....." << endl;
		cout << "check file status...." << endl;
		cout << "open file........." << endl;
		Serialize(); //调用其虚函数
		cout << "close file......" << endl;
		cout << "update all views......" << endl;
	}

	virtual void Serialize() {};
};

class CMyDoc : public CDocument
{
public:
	virtual void Serialize() //对虚函数进行编写
	{
		cout << "CMyDoc::Serialize()" << endl;
	}
};


int _tmain(int argc, _TCHAR* argv[])
{
	CMyDoc myDoc;
	myDoc.OnFileOpen();

	return 0;
}

猜你喜欢

转载自blog.csdn.net/zxl2712028/article/details/81430500