Tools.h++ Manual
3-6 104011 Tandem Computers Incorporated
3
Comparisons
Finally, most classes have comparison and equality member functions:
int compareTo(ClassName*) const;
RWBoolean equalTo(ClassName*) const;
and their logical operator counterparts:
RWBoolean operator==(const ClassName&) const;
RWBoolean operator!=(const ClassName&) const;
RWBoolean operator<=(const ClassName&) const;
RWBoolean operator>=(const ClassName&) const;
RWBoolean operator<(const ClassName&) const;
RWBoolean operator>(const ClassName&) const;
3.4 Memory allocation
When an object is allocated off the heap, ownership can be a problem: who is
responsible for deleting it?
All of the Tools.h++ classes take a very simple approach: if you allocated
something off the heap, then you are responsible for deallocating it. If the
Tools.h++ library allocated something off the heap, then it is responsible for
deallocating it.
There are two exceptions. The first are the operators
RWFile& operator>>(RWFile& file,
RWCollectable*&);
RWvistream& operator>>(RWvistream& vstream,
RWCollectable*&);
These operators restore an object inheriting from
RWCollectable
from an
RWFile
or
RWvistream
, respectively. They return a pointer to an object
allocated off the heap: you are responsible for deleting it.
The second exception is member function
RWCollection* RWCollection::select(RWtestCollectable,
void*) const;