Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
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.

CArchive::ReadObject

Reads object data from the archive and constructs an object of the appropriate type.

CObject* ReadObject( 
   const CRuntimeClass* pClass  
);

pClass

A constant pointer to the CRuntimeClass structure that corresponds to the object you expect to read.

A CObject pointer that must be safely cast to the correct derived class by using CObject::IsKindOf.

This function is normally called by the CArchive extraction (>>) operator overloaded for a CObject pointer. ReadObject, in turn, calls the Serialize function of the archived class.

If you supply a nonzero pClass parameter, which is obtained by the RUNTIME_CLASS macro, then the function verifies the run-time class of the archived object. This assumes you have used the IMPLEMENT_SERIAL macro in the implementation of the class.

See the example for CArchive::WriteObject.

Header: afx.h

Community Additions

ADD
Show:
© 2015 Microsoft