//自定义类
//注意要在自定义类中动态串行化宏声明
void CAge::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{ // storing code
ar<< val ;
}
else
{ // loading code
ar >> val ;
}
}
//文档类的析构函数
CTestDoc::~CTestDoc()
{
//循环遍历, 微软说这样安全
POSITION pos ;
for (pos = list->GetHeadPosition(); pos != NULL; list->GetNext(pos))
{
CAge* n = (CAge*) list->GetAt(pos); // Save the old pointer for
delete n; // Deletion avoids memory leak.
}
list->RemoveAll();
}
//文档类的串行化
void CTestDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
//文档类中的自定义成员变量
ar << list ;
}
else
{
// TODO: add loading code here
ar >> list ;
}
}