Practical C++ Programming, 2nd Edition by Steve Oualline This errata page lists errors outstanding in the most recent printing. If you have technical questions or error reports, you can send them to booktech@oreilly.com. Please specify the printing date of your copy. This page was updated March 3, 2008. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification Confirmed errors: The chapter on Portability Problems, which was supposed to be Chapter 26, was inadvertantly left out of the book. You can download a pdf of the missing chapter here - http://examples.oreilly.com/9780596004194/ch25.pdf (xix) middle of page; The sentence "C++ does introduce a number of new minor improvements to C++" should read "C++ does introduce a number of new minor improvements to C" [235] Code snippet after 1st paragraph; for (current = 0; current = number_of_entries; ++current) should be: for (current = 0; current < number_of_entries; ++current) (31) 5th paragraph; When discussing indentation example 3-1 is referred to. Example 3-1 is the "Hello World" program on page 25, not the code on page 30 to which the discussion refers. (36) 6th paragraph; "Now let's take a look at the 'Hello World' program (Example 1-1)" should say Example 3-1, not 1-1. {41} under the topic of Integers; -9223372036854775807 (-2^63) should be: -9223372036854775808 (-2^63) (46) Sidebar on Legacy Boolean Types; "These names are depreciated ..." SHOULD BE "These names are deprecated ..." (55) Example 5-7, as well as the first code snippet after Example 5-7; The code is correct, but the use of #include is old fashioned. This should be changed to the more modern: #include {66} Example 5-12; int main() { std::cout ...... Should read: int main() { ch = 37; std::cout ...... (79) IN PRINT: "while Statement" section, 3rd paragraph "...Example 6-2 computes all the Fibonacci numbers..." SHOULD BE: "...Example 6-1 computes all the Fibonacci numbers..." (126) Example 9-2. Add as first line: #include [134] 4th paragraph; According to the book, when passing a multidimensional array as a parameter to a function, C++ requires that you put in "the size for each dimension except the last one." The book's example shows: int sum_matrix(int matrix1[10][10]); // Legal int sum_matrix(int matrix1[10][]); // Legal int sum_matrix(int matrix1[][]); // Illegal However, when using the notation of the second of the three examples given, my g++ compiler issues the error, "declaration of .array. as multidimensional array must have bounds for all dimensions except the first." Thus legal usage of multidimensional arrays as function parameters appears to be: int sum_matrix(int matrix1[][10]; // Legal rather than: int sum_matrix(int matrix1[10][]); // Illegal (143) IN PRINT: Under "Programming by successive experimentation"; your refine your remove SHOULD BE you refine you remove (175) IN PRINT: Top; Answer 11-2 and Answer 11-3 should read Answer 11-1 and Answer 11-2 respectively. SHOULD BE: Change "Answer 11-2" to "Answer 11-1" Change "Answer 11-3" to "Answer 11-2" (181) Last code fragment on the page; The last code fragment on page 181 shows the definition of a union. However, it appears to be missing a necessary semicolon after the closing brace. That is, union value { long int i_value; float f_value; } should instead be, union value { long int i_value; float f_value; }; (184) First paragraph - just below code sample; "In this example we are define..." should read "In this example we are defining..." (192) Third to last line of page 192, in stack_pop function; "inline int stack_pop(struct stack&the_stack)" should read "inline int stack_pop(struct stack& the_stack)" (needs a space). The function appears correctly on page 194. (205) IN PRINT: The line above int_array example(10); // Works with explicit; Now the we can initialize our variable using the constructor: SHOULD BE: Now we can initialize our variable using the constructor: (235) code fragment; in the for loop the variable "current" is initialized with zero. After each run it is assigned the variable "number_of_entrys" which is never changed... The code fragement should read: for (current = 0; current < number_of_entries; ++current) { list_ptrs[current] = &list[current]; } // Sort list_ptrs by zip code (248) IN PRINT: The paragraph below the description on delim in parentheses; (And end-of-string('\0') is store in to terminate the string.) SHOULD BE: (And end-of-string('\0') is stored in to terminate the string.) (260) After the two "size" paragraphs; At the top of the page, "The format of the READ call is:" is at the left margin. However, the corresponding paragraphs for the WRITE and CLOSE calls are not aligned to the left margin. (271) IN PRINT: Why 1? box. First line; ...you'll see that it the number of bytes... SHOULD BE: ...you'll see that the number of bytes... (273) First paraphgraph under Reliablilty; "detects the type of the variable and performs the approbate conversion" should be: "detects the type of the variable and performs the appropriate conversion" {288} line 52 of example code; std::sscanf(line, "0", data[max_count]); should be std::sscanf(line, "%d", data[max_count]); <306> IN PRINT: Half-way down; "Question 17-1" missing before "Why does memset successfully initialize the matrix to -1, but when we try to use it to set every element to 1, we fail?" SHOULD BE: "Question 17-1 Why does memset successfully initialize the matrix to -1, but when we try to use it to set every element to 1, we fail?" (307) in the "Pointers" description; "using pointers to go through an array is generally faster using an index, ..." should be: "using pointers to go through an array is generally faster than using an index, ..." (311) 2nd table on page; When adding up the values of the two fixed-point numbers the external representation is 69.12 while the internal representation is 6192. The internal representation should be 6912. (312) first paraphraph after code snippets; "so we must cast fixed_exp do a double" should be: "so we must cast fixed_exp to a double" (314) 75% down the page: return (fixed_pt(oper1.value + oper2.value); Should be: return (fixed_pt(oper1.value + oper2.value)); (317), Unary Operators, the code: inline fixed_pt operator - (const fixed_pt& oper1, const double oper2) { return (fixed_pt(-oper1.value - fixed_pt::double_to_fp(oper2)); } should be: inline fixed_pt operator - (const fixed_pt& oper1) { return (fixed_pt(-oper1.value)); } (346) Sidebar, line 1; Change "Cal Tech" to "Caltech". The nickname for the California Institute of Technology is "Caltech". Visit http://www.caltech.edu/ to verify. (355) 1/2 way down the page: before_ptr = first_ptr; should be after_ptr = first_ptr; (371) short paragraph after point #2.; "Our basic stack is defined in Example 13-1." The example should be 13-2, not 13-1. (384) Figure 21-3; the box on the right in the second row of Figure 21-3 should read "office" instead of "garage" (413) Bottom quarter; // Number if items in the array Should read // Number of items in the array (435) bottom code snippet #include ; should be #include ; (437) Paragraph below the code snippet that begins with #include ; Inserting an item into a map is a little trickier that inserting one should be - Inserting an item into a map is a little trickier than inserting one ("than" instead of "that") (452) Last sentence of the first paragraph under 'Global variables'; Thing were probably simple before... should be - Things were probably simple before... (455) First paragraph on the top; Let's first take a look at an example of what not do to. should say - Let's first take a look at an example of what not to do. (switch "to" and "do") [457] Figure 26-3; The boxes for 'Panel output' and 'Panel input' should be switched. (459) bottom of code; "class _electrice_motor : public generic_locomotive" should be: "class _electric_motor : public generic_locomotive" (462) IN PRINT: 3rd code sample, 1st line; "...to a difficult code resue problem..." SHOULD BE: "...to a difficult code reuse problem..." (506) Example 29-1; in the switch statement. defualt should read default