1 2 3 4 5 6 7 8 9

Destructors


These are the "grim reapers" of the object world. They are
only called when an object is being eliminated.


Again they are identified by the same name as the class, but
with a
"~"prefix:


Complex :: ~Complex() {
cout << "One less complex variable ..." << endl;
}


As in the construction case, the memory used by the data
members of the object are automatically handled by the
system.


Use the destructors to clean up the additionalresources
used by the object, or to keep track of how many objects of
a certain class still exist.


Member functions


Member functions must be listed in the class declaration,
and so belong to the class. Their operation can be defined
inside the class, or outside as is common:

void Complex :: conjugate() {
imaginary= - imaginary;
}

// being declared outside

8 March, 1998

Page {PAGE }

TAM/DS