Walls and Mirrors: C++  (3rd ed) Errata
Walls and Mirrors: C++ (3rd ed) Errata
Last updated on May 5, 2004 
 
 
Note: Check 
Carrano's web page
for recent updates to this document.
 
 =========================================================================
 
Table of Contents
  
 
Page xiii
 
Part II is listed as beginning on page 249 - it begins on 271.
 
 
===========================================================================
 
Chapter 1
 
--------------------------------------------------------------------------- 
 
 
Page 8, Line 8 
 
 
Change math.h to cmath
 
 
--------------------------------------------------------------------------- 
 
 
Page 48, Exercise 3 
 
 
Replace
 
 
#include <iostream.h> 
 
 
with
 
#include <iostream>
 
using namespace std;
 
--------------------------------------------------------------------------- 
 
 
Page 49, Exercise 8 
 
 
Replace
 
 
#include <iostream.h> 
 
 
with
 
#include <iostream>
 
using namespace std;
 
===========================================================================
 
Chapter 2
 
--------------------------------------------------------------------------- 
 
 
Page 63 bottom of page just above last row of boxes 
 
 
add "of" before "fact"
 
 
--------------------------------------------------------------------------- 
 
Page 105, Exercises 8 and 9:
In the include statements, replace iostream.h with iostream
--------------------------------------------------------------------------- 
 
Page 106, Exercise 11:
In the include statement, replace iostream.h with iostream
===========================================================================
 
Chapter 3
 
--------------------------------------------------------------------------- 
 
 
Page 140 middle of page
 
 
1. In the include statement, replace iostream.h with iostream
2. Change 5.0 to 5.1 in:
 
 
Sphere mySphere(5.1);       // radius is 5.0
 
 
to
 
 
Sphere mySphere(5.1);       // radius is 5.1
 
 
---------------------------------------------------------------------------
 
Page 141 middle just before private
 
 
change
 
 
Color getColor();
 
 
to
 
 
Color getColor() const;
 
 
[note that const is BOLD]
 
---------------------------------------------------------------------------
 
Page 142 code before first paragraph
 
 
change
 
 
Color ColoredSphere::getColor()
 
 
to
 
 
Color ColoredSphere::getColor() const
 
 
[note that const is BOLD]
 
---------------------------------------------------------------------------
 
Page 153  
 
 
Our definition of ListException is derived from exception. Some compilers do
 
not provide a constructor for exception that has a string argument.  In such cases, 
 
you can replace exception with another class derived from exception that does 
provide a constructor with a string argument. For example, you could use runtime_error
or logic_error.
 
 
---------------------------------------------------------------------------
 
Page 154  
 
 
Some compilers insist that a function definition contain a "throw" clause if the 
function's prototype has one. If you encounter this error, simply add this clause 
to the function definition.
 
 
=========================================================================
Chapter 4
 
--------------------------------------------------------------------------- 
Page 172, 3rd paragraph
 
 
Replace the first sentence with
You also can use a pointer offset notation to reference any array element.
Replace the sentence in parentheses with
This notation uses pointer arithmetic. 
--------------------------------------------------------------------------- 
 
Page 177 2nd paragraph, Line 4
 
 
Change *Node to Node*
--------------------------------------------------------------------------- 
 
Page 186  2nd sentence of 2nd full paragraph 
 
 
 
Change 
 "Note that we declare a node for the linked list here, but we hide its definition in the implementation file."
to
 "Note that you define the node for the linked list in the private section of the class."
--------------------------------------------------------------------------- 
 
Page 188, Line 4 
 
 
 
Change 
 List yourList = myList;
to
 List yourList(myList);
---------------------------------------------------------------------------
 
Page 203 
 
 
 
change (at the first bold void)
 
 
void linkedListInsert(Node *& headPtr,
 
                                ItemType newItem)
 
 
to
 
 
void linkedListInsert(Node *& headPtr,
 
                                ListItemType newItem)
 
 
---------------------------------------------------------------------------
 
Page 203  
 
 
change != to == in 2nd 'if':
 
 
      if (newPtr != NULL)
 
 
to
 
 
      if (newPtr == NULL)
 
 
 
---------------------------------------------------------------------------
 
Page 223 at bottom
 
 
change order of
 
 
apples
 
bread
 
juice
 
 
to
 
 
juice
 
bread
 
apples
 
 
===========================================================================
 
Chapter 5
 
 
---------------------------------------------------------------------------
 
page 240 - 241
 
 
displayBoard(), isUnderAttack(), and index() should be const methods
 
 
 
---------------------------------------------------------------------------
 
page 250
 
 
In first line above last paragraph:
 
 
change case in
 
 
< identifier > = A | B | ... | Z
 
 
to
 
 
< identifier > = a | b | ... | z
 
---------------------------------------------------------------------------
 
page 250
 
 
change last word in 5th line from bottom:
 
 
uppercase
 
 
to 
 
 
lowercase
 
 
 
---------------------------------------------------------------------------
 
page 251
Replace 4th line from bottom with
+endPre(in first: integer): integer
---------------------------------------------------------------------------
 
page 252 
 
 
In 7th line of code above text:
 
 
change
 
 
      if (firstEnd > 0)
 
 
to
 
 
      if (firstEnd > -1)
 
 
---------------------------------------------------------------------------
 
page 255
 
 
In the first line
 
 
change
 
 
evaluatePrefix(in
 
to
 
 
evaluatePrefix(inout
 
 
In middle of page, sentence before heading "Postfix expressions"
 
 
change
 
 
value parameter
 
to
 
 
reference parameter
 
and
 
 
not saved
 
to
 
 
saved
 
 
 
In middle of page, 5th line after heading "Postfix expressions"
 
 
change case in
 
 
< identifier > = A | B | ... | Z
 
 
to
 
 
< identifier > = a | b | ... | z
 
 
---------------------------------------------------------------------------
 
page 256
 
 
In sentence before pseudocode for convert 
 
 
change
 
 
value parameter
 
to
 
 
reference parameter
 
 
In next line
 
 
change
 
 
convert(in
 
to
 
 
convert(inout
 
---------------------------------------------------------------------------
 
page 257
 
 
In 9th line from top
 
 
change case in
 
 
< identifier > = A | B | ... | Z
 
 
to
 
 
< identifier > = a | b | ... | z
 
 
---------------------------------------------------------------------------
 
page 269
 
 
In 6th line from bottom
 
 
change case in
 
 
< letter > = A | B | ... | Z
 
 
to
 
 
< letter > = a | b | ... | z
 
 
===========================================================================
 
Chapter 6
 
 
---------------------------------------------------------------------------
 
Page 275, 3 lines above Key concepts
 
 
Change "is it" to "it is"
 
 
---------------------------------------------------------------------------
 
Page 312 bottom
 
 
Insert "if (!aStack.isEmpty())" before the last line (the call to getTop)
 
 
===========================================================================
 
Chapter 7
 
--------------------------------------------------------------------------- 
 
Page 334
 
 
Figure 7-2: 
 
The contents of the queue after the first dequeue operation is 2 7 
 
The contents of the queue after the second dequeue operation is 7 
 
 
--------------------------------------------------------------------------- 
 
Page 335
 
 
Add a close brace to the "if (queueFront equals stackTop)" clause 
 
near the bottom of the page. 
 
 
--------------------------------------------------------------------------- 
 
Page 340
 
 
Change the order of the following declarations in lines 5 & 6 
 
 
   QueueNode *frontPtr;
 
   QueueNode *backPtr;
 
 
to 
 
 
   QueueNode *backPtr;
 
   QueueNode *frontPtr;
 
 
to match the order of the initializers in the default constructor.
 
 
--------------------------------------------------------------------------- 
 
Page 341
 
add the next line at top of page, then skip a line. Align it with the slashes at the top of 341.
 
newPtr->next = NULL;
 
 
--------------------------------------------------------------------------- 
 
Page 341
 
 
Change original line 7
 
newPtr->next = backPtr;
 
 
to
 
 
backPtr->next = newPtr;
 
 
--------------------------------------------------------------------------- 
 
Page 350  
 
 
Change L to aList 2x in Line 5:
 
 
      Queue::Queue(const Queue& Q): L(Q.L)
 
 
to
 
 
      Queue::Queue(const Queue& Q): aList(Q.aList)
 
 
--------------------------------------------------------------------------- 
 
Page 351  
 
 
In  the method getFront, remove the ! from the "if" statement so that it reads 
 
 
      if (aList.isEmpty())
 
 
========================================================================
 
Chapter 8
 
---------------------------------------------------------------------------
 
 
Page 378, 3rd line from bottom
 
Insert & after "string"
 
---------------------------------------------------------------------------
 
 
Page 379
 
Insert & after "string" in the methods getName, setName, and resetBall
 
---------------------------------------------------------------------------
 
 
Page 380
 
Insert & after "string" in the constructor and the methods getName, setName, and resetBall
 
---------------------------------------------------------------------------
 
 
Page 415
 
The declaration of count should be just before the  for statement, not within it. 
---------------------------------------------------------------------------
 
 
Page 430, Problem 12.
 
In the last two paragraphs, change "Programing" to "Programming"
 
===========================================================================
 
Chapter 9
 
---------------------------------------------------------------------------
 
Page 456
 
 
Change in Line 6 of first paragraph:
 
 
    Figure 9-9 (page 460)
 
 
to
 
 
    Figure 9-9 (page 458)
 
 
---------------------------------------------------------------------------
 
Page 479
 
 
Exercise 16: The two calls to "mystery" should be in lowercase
 
===========================================================================
 
Chapter 10
 
---------------------------------------------------------------------------
 
Page 485, first line
 
 
Change "valued-oriented" to "value-oriented" 
---------------------------------------------------------------------------
 
Page 495, Figure 10-9
 
 
Add the method attachLeft() to the UML diagram, just before attachRight() 
---------------------------------------------------------------------------
 
Page 499
 
 
Missing semicolon after 7th line from bottom:
 
 
                  int left, int right);
 
 
---------------------------------------------------------------------------
 
Page 501 Figure 10-11
 
 
The brace for the free list should extend up one more item (to item 6)  
---------------------------------------------------------------------------
 
Page 541
 
 
Delete semicolon at end of Line 8:
 
 
   void deleteItem(TreeNode * &treePtr, KeyType searchKey)
 
         throw (TreeException);
 
 
---------------------------------------------------------------------------
 
Page 566, Problem 5
 
 
In  the description of "Quit", change "address book" to "phone book"
 
 
===========================================================================
 
Chapter 11
 
---------------------------------------------------------------------------
 
Page 612
 
 
Self-Test Exercise #4 should refer to Figure 11-11, not 11-10.
 
 
===========================================================================
 
Chapter 12
 
---------------------------------------------------------------------------
 
Page 669
 
 
change ptrType to ChainNode * in Line 13:
 
 
      typedef ptrType HashTableType[HASH_TABLE_SIZE];
 
 
to
 
 
     typedef ChainNode * HashTableType[HASH_TABLE_SIZE];
 
 
---------------------------------------------------------------------------
 
 
========================================================================
 
Chapter 13
 
---------------------------------------------------------------------------
 
 
Page 705, 4th line after "Spanning Trees" heading
 
 
Change "hierarchal" to "hierarchical" 
---------------------------------------------------------------------------
 
 
Page 718, last paragraph
 
 
Change
 
 
 Finding an Euler circuit is like drawing each of the diagrams in Figure 13-28 without lifting your pencil or redrawing a line.
 
 
to
 
 
  Finding an Euler circuit is like drawing each of the diagrams in Figure 13-28 without lifting your pencil or redrawing a line, and ending at your starting point.
 
 
========================================================================
 
 
Appendix A
 
---------------------------------------------------------------------------
 
 
Page A6, 2nd paragraph:
Change limits.h to climits
  
Change float.h to cfloat
 
 
---------------------------------------------------------------------------
 
 
Page A12, 2nd paragraph:
Change  iostream.h to  iostream 
  
---------------------------------------------------------------------------
 
 
Page A15, first line of first full paragraph, 
  
Change 4.000000 to 4.00000
---------------------------------------------------------------------------
 
 
Page A19 (the code) 
  
Change 
#include <iostream.h> 
to
#include <iostream>
using namespace std; 
---------------------------------------------------------------------------
 
 
Page A19 Last paragraph: 
  
Change ctype.h to cctype  twice.
 
 ---------------------------------------------------------------------------
 
 
Page A34 Next-to-last paragraph: 
  
Change string.h to cstring
 
 
---------------------------------------------------------------------------
 
 
Page A53 Closing a file
  
Delete the following sentences and the margin note:
"You can have at most one input file and one output file 
open at any one time. If you have an input file open, for example, and 
you need to read from another file, you must close the current input file 
and open the new one."
---------------------------------------------------------------------------
 
 
Page A67, near bottom of page
  
Delete the duplicate "case constantn:
---------------------------------------------------------------------------
 
 Page A73, Exercise 5b, last line
 
Change the first occurrence of "minTemps" to "mt"
 
---------------------------------------------------------------------------
 
 
========================================================================
 
Appendix C
 
---------------------------------------------------------------------------
 
 Page A78, 4th line from bottom
 
 
Change "arc cosine" to "hyperbolic cosine"
 
========================================================================
 
 
Inside back cover, 3rd line
 
 
Change "mutiply" to "multiply"
 
---------------------------------------------------------------------------
 
========================================================================
 
 
Index
 
---------------------------------------------------------------------------
 
 
p I15 
  
 
sort/stability of sorting
   
 
Change
 
 
482 to 480 
 
 
---------------------------------------------------------------------------
 
 
p I16 
  
 
stable sorting algorithms  
   
 
Change
 
 
482 to 480