person.cpp
来自「本程序介绍vc中串行化方法」· C++ 代码 · 共 47 行
CPP
47 行
// 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 + =
减小字号Ctrl + -
显示快捷键?