|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Serialization: Serializing an Object
The article Serialization: Making a Serializable Class shows how to make a class serializable. Once you have a serializable class, you can serialize objects of that class to and from a file via a CArchive object. This article explains:
- What a CArchive object is.
- Two ways to create a CArchive.
- How to use the CArchive << and >> operators.
- Storing and loading CObjects via an archive.
You can let the framework create the archive for your serializable document or explicitly create the CArchive object yourself. You can transfer data between a file and your serializable object by using the << and >> operators for CArchive or, in some cases, by calling the
Serialize function of a CObject-derived class.