Errata

Practical C++ Programming

Errata for Practical C++ Programming

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 44
3rd line

floating = (1 / 2) + (1 / 2); // assign floating 0.0

Should be :

floating = (1 / 2) - (1 / 2); // assign floating 0.0

Laetitia  Aug 01, 2010 
50
in the errata!

Author has this note on the errata page re p50 explanation of substr():

Note from the Author or Editor:
Correction follows: the general form of this function is: string.substr(first, length) This function returns a string containing all the character starting with first and going for length characters (or to the end of the string). For example, the following code assigns the variable sub_string the word is: // 01234567890123 main_string = "This is a test"; sub_string = main_string(5, 2);

But the author's revision is still incorrect: this time it omits the name of the operation it's attempting to describe! I think the line should read:
sub_string = main_string.substr(5, 2);

Carl Barlow  Jun 16, 2010 
Printed Page 130
1st paragraph (namespace math)

I cannot understand how the author shows that all functions in a namespace do not need a 'using' clause or a 'namespace' qualification.
My guess is that function 'area' should return "PI*square(radius)", so it uses a function defined in 'math' in te previous page and it evaluates the area of a circle and not the circumference (which is not an 'area').

Anonymous  Aug 08, 2015 
Printed Page 158
Answer 10-4

There should be one more semicolon at the end of line" std::cout<<"Fatal Error: Abort\n";exit(8) ;"
Because there was one semicolon in the end of the macro "DIE" and the other is given in c++.

Thanooj  Apr 06, 2022 
Printed Page 190
Middle

"int two_bits:3" should be "int two_bits:2"

Darren Harker  Jan 13, 2011 
Printed Page 206
1/3 down

"...all functions declared in a class..." should be "...all functions defined in a class..."

Darren Harker  Jan 13, 2011 
PDF Page 231
231 (top - code snipped)

missing '}' for the first init_array_1() function definition. confirmed with the downloaded sample code

Baskin Tapkan  Nov 07, 2012 
Printed Page 325
Casting

The statement: "C++ automatically calls this function whenever it wants to turn a fixed_pt into a long int."

This is misleading or false, as the code is: operator double() {return (value / fixed_exp);}

This would mean the operator would return double, but the author states that C++ will use this to cast to long int.

Aaron Pitman  Jul 17, 2022 
Printed Page 325
Casting

The statement: "C++ automatically calls this function whenever it wants to turn a fixed_pt into a long int."

This is misleading or false, as the code is: operator double() {return (value / fixed_exp);}

This would mean the operator would return double, but the author states that C++ will use this to cast to long int.

Aaron Pitman  Jul 17, 2022 
Printed Page 355
Israel

The function that inserts a node at head of ordered linked list does not work correctly.
As it explained on Figure 20-5 there is the following ordered list:

first_ptr --> 45 ----next_ptr--->89----next_ptr--->123---->NULL

In order to create such a list one needs to insert values as follows:
1) 123 - the end of the list
2) 89 - the middle of the list
3) 45 - the head of the list

But when one uses this function to add a node in the middle of this ordered list there is a problem:
The current function (p.355 ) starts to check the values from the head of the list.
Because of the statement
if ( item >= after_ptr->data )

1) the function checks if 53 >= 89, no.
2) it proceeds to the next node.
3) the function checks if 53 >= 123, no.
4) it proceeds to the next node.
5) the function checks if after_ptr = NULL, yes.
6) break;
6) The node is added to the end of the lists instead of the appropriate place.
This way the list is no longer ordered.

To fix this issue there is a need to change a statement to
if ( item <= after_ptr->data )
Or to change the order of insertion of values to a linked list as follows:
1) 45
2) 89
3) 123

Andrei Cheremskoy  Jul 21, 2012 
Printed Page 372,373
function definiton

In the function definition for push_three() and push(), the second parameter is "const int item 3" which is incorrect and should be "const int item2".

Anonymous  May 12, 2010 
Printed Page 373
code at top of page

The reference to "stck" (as in stck::push(item1);")should, I believe, be "stack". This error is repeated 3 times in same code snippet.

The comment seem wrong too. Shouldn't it say "This calls push in the stack class"? According to text on page 372, calling push in m_stack was what we did not want to do.

Note from the Author or Editor:
Confirmed.

Joe Barcelo  Feb 06, 2010 
Printed Page 373
Code at top

"stck::push..." should be "stack::push..." x3

Darren Harker  Jan 13, 2011 
Printed Page 387
Question 21-1

The text "Why does Example 21-1 fail..." should be "Why does Example 21-5 fail...".

Anonymous  May 12, 2010 
Printed Page 387
2/3 down

"Why does Example 21-1 fail..." should be "Why does Example 21-5"

Darren Harker  Jan 13, 2011 
Printed Page 462
3rd Paragraph

"...fact that each mode..." should be "...fact that each node"

Darren Harker  Jan 13, 2011 
Printed Page 467
Code in middle

"the_impelementation" should read "the_implementation"

Darren Harker  Jan 13, 2011 
Printed Page 477
Code Comment

"This is a mult-line comment" should be "This is a multi-line comment"

Darren Harker  Jan 13, 2011