Return type of operator>>(), Rwthrow macro is discussed in, Chapter 19 – HP Integrity NonStop J-Series User Manual

Page 286

Advertising
background image

Click on the banner to return to the user guide home page.

©Copyright 1996 Rogue Wave Software

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;

}

Advertising
This manual is related to the following products: