Tools.h++ Manual
16-6 104011 Tandem Computers Incorporated
16
However, you do not have to know these details until you write your own 
class 
RWCollectable 
class, something we will do in the following chapter. 
However, at this point, you should note that when Smalltalk-like collection 
classes are restored they necessarily do not know the types of objects they will 
be restoring. Hence, they must allocate them off the heap. This means that 
you are responsible for deleting the restored contents. This happened in line 11 
of the example.
16.3 Summary
In the example in the previous section we saw the use of two operators for 
storage and retrieval, respectively, into virtual streams:
RWvostream& operator<<(RWvostream&, const
RWCollectable&); // 1
RWvistream& operator>>(RWvistream&,
RWCollectable&); // 2
There are two similar operators for storage and retrieval into 
RWFile
’s:
RWFile& operator<<(RWFile&, const
RWCollectable&); // 3
RWFile& operator>>(RWFile&,
RWCollectable&); // 4
In addition to these operators, there are also two operators for storage of 
pointers to 
RWCollectables
. These operators have nearly identical 
semantics to their “const reference” counterparts (functions 1 and 3, 
respectively). The only difference is that they can detect and restore nil 
pointers.
RWvostream& operator<<(RWvostream&, const
RWCollectable*); // 5
RWFile& operator<<(RWFile&, const
RWCollectable*); // 6










