Using the same CArchive object for archive and un-archive
Posted
by bdhar
on Stack Overflow
See other posts from Stack Overflow
or by bdhar
Published on 2010-06-09T11:16:34Z
Indexed on
2010/06/09
11:22 UTC
Read the original article
Hit count: 229
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.
© Stack Overflow or respective owner