 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
Whenever
we have virtual functions, we should always
|
|
|
declare
the destructor to be virtual.
|
|
|
| • |
Making
the destructor virtual will ensure that the correct
|
|
|
destructor
will be called for an object when pointers to
|
|
|
direct
or indirect base classes are used.
|
|
|
| • |
If
the destructor is not declared to be virtual, then the
|
|
|
destructor
is statically bound based on the type of pointer
|
|
or
reference and the destructor for the actual object
|
|
|
pointed
to will not be called when the object is
|
|
|
deallocated.
|
|
|
| • |
In
the account class’ public section add:
|
|
|
virtual ~account();
|
|