Chapter 4 comments

Here are my comments on what you submitted for Chapter 4.

ex4.1: if you inspect the output of your program carefully, you'll notice that not all of Telephone's underlying objects are copied (one can tell because not all of the expected "Copy Constructor" messages show up). Please fix.

ex4.2: I have two comments on your CaloGrid::cell() member function:

  1. The condition used in the non-const version is not entirely complete, as also negative values of x or y are invalid.
  2. The const_cast as used in the const version actually does not work. Unfortunately the compiler will happily use the non-const version as long as that is possible (i.e., as long as a non-const CaloGrid object is involved), but I invite you to try with a const CaloGrid object. Also, do you really need the CaloCell and Point copy constructors and destructors?

ex4.3: can you elaborate on why you choose to implement operator+() as a member function rather than a global function? Also, I'm missing an answer to the question why operator+=() with a string literal works. Finally, in operator()(), you need a delete[] rather than a delete statement -- my compiler warns me about this.