Tools.h++ Manual

104011 Tandem Computers Incorporated 20-3
20
20.3 Return type of operator>>()
An extremely common mistake is to forget that the functions
RWvistream& operator>>(RWvistream&, RWCollectable*&);
RWFile& operator>>(RWFile&, RWCollectable*&);
return their results off the heap. This can result in a memory leak:
20.4 Include path
Make sure that when you specify an include path to the Tools.h++ header files
that it does not include a final "
rw
":
main()
{
RWCString* string = new RWCString;;
RWFile file(“mydata.dat”);
// WRONG:
file >> string;// Memory leak!
// RIGHT:
delete string;
file >> string;
}
# Use this:
CC -I/usr/local/include -c myprog.C
# not this:
CC -I/usr/local/include/rw -c myprog.C