⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 person.cpp

📁 本程序介绍vc中串行化方法
💻 CPP
字号:
// Person.cpp: implementation of the CPerson class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Serialize.h"
#include "Person.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

IMPLEMENT_SERIAL(CPerson,CObject,1)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPerson::CPerson()
{
    //Initialize the class variables
	m_iMaritalStatus=0;
	m_iAge=0;
	m_bEmployed=FALSE;
	m_sName="";
}

CPerson::~CPerson()
{

}

void CPerson::Serialize(CArchive &ar)
{
    //Call the ancestor function
	CObject::Serialize(ar);

	//Are we writing?
	if(ar.IsStoring())
		//Writing all of the variables,in order
		ar<<m_sName<<m_iAge<<m_iMaritalStatus<<m_bEmployed;
	else
		//Read all of the variables,in order
		ar>>m_sName>>m_iAge>>m_iMaritalStatus<<m_bEmployed;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -