First Printing Errata (Jan 11, 2013)

 
Chapter 2

Page 41, Listing 2.5, the program works on Visual C++ 2012. On other compilers, replace line 2 with

#include <climits>
#include <cfloat>

Page 49, three lines before Table 2.3, change count += 8 to count += 1.

Page 61, line -3, change "too large" to "too small".

Page 64, item #20 in the Chapter Summary, change (type) to static_cast.

Chapter 3

Page 91, Line 1, change -1 to 0. 

Page 88, in the Trace Program box of Listing 3.3, change 130599 to 117684. 

Chapter 4

Page 120, replace the Note in the middle of the page as follows: The functions min, max, and abs are defined in the cstdlib header in GNU C++, but min and max are defined in the algorithm header in Visual C++ 2013.

Page 127, in the middle of the paragraph, change ('a' + rand) to 'a' + rand().

Page 134, line --11. insert "When you declare a variable of an object type, the variable actually represents an object. Declaring an object actually creates an object." after the sentence "It is known as an object type.".

Page 141, in Table 4.8, Change the header Operator to Manipulator. 

Page 145, in Figure 4.3, change scores.txt to numbers.txt.  

Page 146, in the middle of this page, change "<<" to ">>" for input << score1; input << score2; input << score3; and input << score1 << score2 << score3;

Page 146, in Figure 4.4, change scores.txt to numbers.txt.  

Page 146, just before Listing 4.10, change "writing data" to "reading data".  

Page 147, in the item #1 in Chapter Summary, change cell to ceil.

Page 175, line 2, change 5.24 to 5.27.

Page 154, in Exercise 4.23, Insert "Your program should check whether the input is valid." before Here are sample runs.

Chapter 5

Page 166, in Listing 5.6, line 8, change score.txt to numbers.txt.

Page 167, add a NOTE right before Check Point 5.1. Click here to see the note.

Page 177, in Listing 5.8, move line 8 to line 16.

Chapter 6

Page 245, line 3 in Section 6.15.3, change getTotalNumberOfDaysInMonth to getNumberOfDaysInMonth.

Page 259, line 3 in Programming Exercise 6.35, change y5 to y4.

Page 259, line 2, change x = 0 to c = 0.

Chapter 7

Page 266, line -6, change line 11 to line 14.

Page 268, last line -6, change the last myList[1] to myList[2].

Chapter 8

Page 339, change the last line of Programming Exercise 8.33 to "The areas are 6.17 7.96 8.08 10.42".

Chapter 9

Page 345, in Figure 9.4, change boolean to bool.

Page 353, in the second line of the first Note, change TestCircleWithDefinition.cpp to TestCircleWithHeader.cpp.

Page 368, line -9, change "the second is 9" to "the second is 10".

Chapter 10

Page 380, in the second line after the first paragraph, replalceString should be replaceString.

Page 380, in (14) and (15) of Check Point 10.2, s3 should be s2.

Page 398, in Figure 10.12, swap the last two numerals 1 and 1.. 3 in the diagram.

Chapter 11

Page 412, in the 8th line in Section 11.2, change "Suppose ..." to "Suppose four variables count, status, letter, and s are defined as follows".

Page 425, in the output of Listing 11.5, change 19 11 12 13 14 15 16 to 11 12 13 14 15 16.

Pages 446-447, in Listing 11.20, insert the following statement before line 57.

 for (int i = 0; i < numberOfStudents; i++)
   students[i] = course.students[i];

Chapter 12

Page 474, change two occurrence of Listing 7.2 to Listing 7.3.

Page 484, line 4, change  & to %.

Chapter 13

Page 502, in Table 13.1, change ios:truct to ios::trunc.

Page 502, in the second line of the first Note, change ios:app to ios::app.

Page 503, in the last line, change ios::truct to ios::trunc.

Page 519, in line 2, change oact/B to oact/b.

Page 518, in item #6, change iso to ios and change truct to trunc.

Page 519, in line 4 befoer "Each file", insert "These files can be directly downloaded from www.cs.armstrong.edu/liang/data/Babynameranking2001.txt, …, and www.cs.armstrong.edu/liang/data/Babynameranking2010.txt."

Chapter 14

Pages 553-554, in Listing 14.12, replace lines 61-64 with the following code: (See http://www.cs.armstrong.edu/liang/cpp3e/html/CourseWithEqualsOperatorOverloaded.html)

 if (this != &course) // Do nothing with self-assignment
 {
   courseName = course.courseName;
   numberOfStudents = course.numberOfStudents;
   capacity = course.capacity;

   delete [] this->students; // Delete the old array

   // Create a new array with the same capacity as course copied
   students = new string[capacity];
   for (int i = 0; i < numberOfStudents; i++)
     students[i] = course.students[i];
  }

Page 544, line 2, change >> to << and change >> to <<.

Chapter 15

Page 567, lines 30 and 31 in Listing 15.7 TestGeometricObject.cpp, change circle to rectangle and change the output for rectangle's color to orange and filled to true.

Page 572, line -6, change this line to "// Use Parent::operator=(object) to apply the assignment operator in the base class." Please see a concrete example on custom copy constructor and custom assignment operator in the base class and in the child class from www.cs.armstrong.edu/liang/cpp3e/html/CustomCopyConstrucotrAssignmentOperatorInParentAndChild.html.

Page 588, in line 4 after the sample output box, change circle1 to circle.

Page 588, two lines before Check Point, change displayObject to displayGeometricObject.

Page 590, in the displayGeometricObject function, change "raidus" to "radius".

Page 595, line -6, change rectangle to triangle.

Chapter 16

Page 616, in the right box of the top diagram, change the first logic_error to TriangleException.

 

Credits: James Chegwidden (Tarrant County College), Mandy Wright (Altamaha Technical College), Ron McCarty (Penn State), Brian Lawson, Dean Kelly (Minnesota State U.), Marcel Manning (Armstrong State U). Abdulhamid Al Salman (Lawrence Technological University), Frank McCown (Harding College), Russell Hires (USF Polytechnic), Kraig Blamires (Idaho State University), Matt Fig (Idaho State U), Linda Cohen (Forsyth Tech, NC), Finn Gustafsson (Technical University of Denmark), Hilda Halliday (Skagit Valley College), Devinder Sodhi, Ming-Jyh Tsai (Fu-Jen University, Taiwan), Devinder Sodhi (Ramapo College), Peter Drinovac, Georgios Christodoulakis (Greece), Dany Anghielo Flores, Michael Bernard (Armstrong State University), Murat Zazi (Ramapo University), Jordan Parkman (Armstrong State University), Steve Ezzell (Tidewater Community College), Daryl H. Hepting (University of Regina, Canada), Chris Samuels (Armstrong State University).
 

Please send errata to y.daniel.liang@gmail.com. Thanks for helping improve the book!