是否能把多个对象序列化到一个文件中, 然后从此文件中反序列化出多个对象解决思路

是否能把多个对象序列化到一个文件中, 然后从此文件中反序列化出多个对象
有一个person类:
class   person   {
    int   id;
    CString   name;
};

假设程序中可能涉及到很多个person对象的序列化,   为了避免产生很多
小的文件

是否能把多个对象序列化到一个文件中,   然后在程序下次启动时从此文件中反序列化出多个person对象??


------解决方案--------------------
当然可以
------解决方案--------------------
肯定可以嘛,不可以的话,软件怎么保存打开。好好看看基础的东西吧。
------解决方案--------------------
完全支持,多看哈MSDN
------解决方案--------------------
“对象序列化”也许实现上有一些技术(其实也就是虚拟函数而已),用起来很简单的,你有多少个变量,就逐个写入/读取即可,只要顺序一致。也可以用列表容器来管理,MFC的列表容器直接支持序列化,不用逐个成员来序列化(其实内部就是个循环)。多看看MFC源代码,可以了解很多东西,也可以学习提高自己的技术。
------解决方案--------------------
boost里面有序列化的功能.

#include <fstream>

// include headers that implement a archive in simple text format
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>

/////////////////////////////////////////////////////////////
// gps coordinate
//
// illustrates serialization for a simple type
//
class gps_position
{
private:
friend class boost::serialization::access;
// When the class Archive corresponds to an output archive, the
// & operator is defined similar to < <. Likewise, when the class Archive
// is a type of input archive the & operator is defined similar to > > .
template <class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & degrees;
ar & minutes;
ar & seconds;
}
int degrees;
int minutes;
float seconds;
public:
gps_position(){};
gps_position(int d, int m, float s) :
degrees(d), minutes(m), seconds(s)
{}
};

int main() {
// create and open a character archive for output
std::ofstream ofs( "filename ");

// create class instance
const gps_position g(35, 59, 24.567f);

// save data to archive
{
boost::archive::text_oarchive oa(ofs);
// write class instance to archive
oa < < g;
// archive and stream closed when destructors are called
}

// ... some time later restore the class instance to its orginal state
gps_position newg;
{
// create and open an archive for input
std::ifstream ifs( "filename ", std::ios::binary);
boost::archive::text_iarchive ia(ifs);
// read class state from archive
ia > > newg;
// archive and stream closed when destructors are called
}
return 0;
}
------解决方案--------------------
Person 类从CObject派生,然后重载Serialize()