The streaming functions for a derived class must explicitly invoke the streaming functions for each base class, in order to stream the full state of the object. Given a class Derived which inherits from class Base:
void Derived::writeToStream(IDataStream& toWhere) const { IStreamOutFrame localFrame(toWhere); Base::writeToStream(toWhere); // Stream out our base class fData >>= toWhere; // then stream out our data members }
The readFromStream function has the same general form:
void Derived::readFromStream(IDataStream& fromWhere) { IStreamInFrame localFrame(fromWhere); Base::readFromStream(); // Stream in our base class fData <<= fromWhere; // then stream in our data members. };
Introduction
to the Streaming Classes
Data Streams
Adding Streaming Support
to Structs and Simple Classes
Creating a Streamable
Class
Creating a Streamable
Template Class
Instantiating a
Stream Module
Enabling
Release-to-Release Data Compatibility
Transitioning from
Older Streaming Constructs