views:

25

answers:

1

Following is a sample code:

CFile serFile;
serFile.Open(_T("Person.ser"), CFile::modeCreate | CFile::modeWrite);

CArchive writer(&serFile, CArchive::store);

me.Serialize(writer);

writer.Close();
serFile.Close();

serFile.Open(_T("Person.ser"), CFile::modeRead);

CArchive reader(&serFile, CArchive::load);
CPerson clone;
clone.Serialize(reader);

reader.Close();
serFile.Close();

Here, I have a writer which archives the object me. Then, I use another CArchive object reader to un-archive it. Is it possible to re-construct or set any property of writer to make it, the reader instead of declaring another CArchive object reader?

Thanks.

A: 

I guess a CArchive *cReadAndWrite pointer can be used and you can delete it and reuse it. But i am not sure on this feasibility.

ckv