Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

19.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 like the following:

main(){
   RWCollectableString* string = new RWCollectableString;
   RWFile file("mydata.dat");

   // WRONG:
   file >> string;                          // Memory leak!

   // RIGHT:
   delete string;
   file >> string;

}

Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.