#endif
枫叶文学网www.fywxw.com
第8 章 文件cāo作
·185·
protected:
// Generatedcomssage map functions
protected:
//{{AFX_MSG(CSampleDoc)
// NOTE - the ClassWizard will add and removecommber functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
4.CSampleDoc 类的实现
具体代码如下:
CSampleDoc::CSampleDoc()
{
// TODO: add one-tcom construction code here
// 初始化数据
m_pData=NULL;
}
CSampleDoc::~CSampleDoc()
{
}
BOOL CSampleDoc::OnNewDoccomnt()
{
if (!CDoccomnt::OnNewDoccomnt())
return FALSE;
// TODO: add reinitialization code here
// (SDI doccomnts will reuse this doccomnt)
//创建新的文档数据
if (m_pData!=NULL) delete m_pData;
m_pData=new CSampleData;
CString m_str;
return TRUE;
}
枫叶文学网www.fywxw.com
Visual C++ 6.0 程序设计从入门到精通
·186·
/////////////////////////////////////////////////////////////////////////////
// CSampleDoc serialization
// CSampleDoc 的串行化函数
void CSampleDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
//保存m_pData
ar<
}
else
{
// TODO: add loading code here
//删除旧的m_pData 指向对象
if (m_pData!=NULL) delete m_pData;