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:
- The condition used in the non-const version is not entirely complete, as also negative values of
xoryare invalid. - The
const_castas 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-constCaloGridobject is involved), but I invite you to try with aconst CaloGridobject. Also, do you really need theCaloCellandPointcopy 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.