Bruce Eckel's Thinking in C++, 2nd Ed Contents | Prev | Next


  1. Prove to yourself that new and delete always call the constructors and destructors by creating a class with a constructor and destructor that announce themselves through cout. Create an object of that class with new, and destroy it with delete. Also create and destroy an array of these objects on the heap.
  2. Create a PStash object, and fill it with new objects from Exercise 1. Observe what happens when this PStash object goes out of scope and its destructor is called.
  3. Create a class with an overloaded operator new and delete, both the single-object versions and the array versions. Demonstrate that both versions work.
  4. Devise a test for Framis.cpp to show yourself approximately how much faster the custom new and delete run than the global new and delete.
Contents | Prev | Next

CodeGuru - the website for developers.