Create
a heap compactor for all dynamic memory in a particular program. This will
require that you control how objects are dynamically created and used (do you
overload
operator
new
or does that approach work?). The typically heap-compaction scheme requires
that all pointers are doubly-indirected (that is, pointers to pointers) so the
“middle tier” pointer can be manipulated during compaction.
Consider overloading
operator->
to accomplish this, since that operator has special behavior which will
probably benefit your heap-compaction scheme. Write a program to test your
heap-compaction scheme.