To make a class A stream class, you first define two member functions Savetostream and Loadfromstream for the class, (how to define see "Simplified handling of stream Class I/O") and then consider the version of the stream in both functions. Examples are as follows:
Class tsome{
Private
int num;
Double sum;
Public
void Savetostream (Tstream*stream)
{///function code needs to see "stream Class I/O simplified processing"
Tdataio < int > (0x10001) >> stream;//Storage Version number 1.1
Tdataio < int > (num) >> stream;//storage num
Tdataio < double > (sum) >> stream;//storage sum
}
void Loadfromstream (Tstream*stream)
{
int Ver=tdataio < int > () << stream;//Read version number
if (ver==0x10001) {
Num=tdataio < int > () << stream;//Read num
Sum=tdataio < double > () << stream;//read sum
}else if (ver==0x10002) {
Here to deal with another version ....
}//end If-else
}//end LoadFrom ...
Other code in class ...
};//end class
--------------------------------------------------------------------------------
When a member of a class changes, it is only necessary to record the corresponding change and give an internal version number that provides the read/save code for each build in the I/O function.