Third Change
After adding these macros, use the new pointer-based operators to write a real_property pointer to an object stream, and then read it back. Note that the serialization factory has constructed a new real_property instance that is now owned by the module calling the input operator. The following is an example of writing a real_property pointer into a file and then reading it back again.
// examples\serial\simple\real_estate2.cpp
real_property real1("1980 Main St. Corvallis, Oregon","50x100");
real_property* real2 = 0;
{
ofstream fout(“real_estate2.dat”);
RWpostream postr(fout);
RWObjectOutputStream out = RWCompactObjectOutputStreamImp::
make(RWDataToVirtualOutputStreamImp::
make(postr)); // 1
out << &real1; // 2
}
ifstream fin("real_estate2.dat");
RWpistream pistr(fin); // 3
RWObjectInputStream in = RWCompactObjectInputStreamImp::
make(RWDataFromVirtualInputStreamImp::
make(pistr)); // 4
in >> real2; // 5