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.
Version |
Location |
Description |
Submitted by |
Date submitted |
PDF |
Page Ex 10-21
Example 10-21 2nd line of int main(int argc, char **argv) |
Code has argv[1] where it should have argv[0].
This causes a segfault instead of returning the program name.
Example 10-21 2nd line of int main(int argc, char **argv)
|
wburchill |
Jan 14, 2021 |
Printed |
Page 4
All chapter 4 |
Hello,
(The problem does not concern page 4, but chapter 4 examples. I haven't browsed the other chapters
yet.)
The uses of stream.eof() and getline are incorrect. The lines should be read with:
while(std::getline(in, tmp, '
'))
see http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.5
|
Anonymous |
|
Printed |
Page 12
Top third of the page in the Tip, suggestion or general note section |
The Tip reads as follows:
Before you start working through the recipes in this chapter, create four sibling directories
johnpaul, geogreringo, hellobeatles, and binaries...
The directory geogreringo is later referenced as georgeringo (which I suspect is the correct name).
|
Anonymous |
|
PDF |
Page 65
middle of the page |
"To delete the executable and the intermediate object file from the makefile directory, enter make clean."
I don't think there is any intermediate object file being created with this Makefile, and even if there is, make will only delete the executable when the clean target is specified:
clean:
rm -f hello
(The top of p. 68 correctly states that only hello (the executable) is deleted.)
|
Mark Rajcok |
Sep 30, 2010 |
Printed, PDF |
Page 80
Makefile 1-23.mak |
1-23.mak
line 20 all: $(HELLOBEATLES)
should be all: $(OUTPUTFILE)
Makefile does not generate an executable without this change.
|
Anonymous |
Jun 06, 2017 |
Printed |
Page 105
Example 2-1 |
In example 2-1 and all following examples, you use
FILENAME_H__ as the include guard.
However, the C++ Standard ISO/IEC 14882:2003 explicitly reserves to the implementation all
identifiers containing a double underscore.
The include guards in the examples should simply use a single trailing underscore:
FILENAME_H_
|
Anonymous |
|
Printed |
Page 125
half way down |
The output shown for example 3-4 should be:
There are 3 ways to do this.
There are Those cost $50.
abc123
rather than:
There are 3 ways to do this.
Those cost $50.
abc123
I ran this example and researched the boost format.hpp and discovered that the code line f.clear()
clears the bound items not the object f as it was declared. so the no bound items. so everything
from %1% on in the declaration of f is cleared.
I compiled the code on MinGW 3.4.2 compiler using Eclipse CDT as my IDE.
|
Anonymous |
|
Printed |
Page 154
Example 4-10 |
The function
void split(...)
you show in this example will fail, if the string does not contain the separator character. The resulting vector<string> will not contain any entries, while I would expect it to contain one entry, the full input string.
A possible solution (add lines marked with a +):
void split(const string& s, char c,
vector<string>& v) {
string::size_type i = 0;
string::size_type j = s.find(c);
+ if (j == string::npos) {
+ v.push_back(s);
+ return;
+ }
while (j != string::npos) {
// ... the while loop as in the example
}
}
|
Fabian Kislat |
Mar 27, 2009 |
Printed |
Page 157
2nd paragraph, Solution section. |
There seems to be a typo in the line that says:
Use find_first_of and first_first_not_of member functions...
Should say:
Use find_first_of and find_first_not_of member functions...
|
William Yee |
Dec 26, 2012 |
Printed |
Page 195
in function "loadCSV" 3rd comment line |
the comment "// Recipe 4.7" should refer to 4.6, i.e. should read
"// Recipe 4.6"
|
Anonymous |
|
Printed |
Page 216
11th line from bottom |
I am not at all a C++ expert so I may have missed something here. However, on page
216 in the initial vector example, the code near the bottom of the page reads:
string s = "Marines";
vector<string>::iterator p = find(strVec.begin(), strVec.end(), s);
if (s != strVec.end()) // Insert s immediately before the element
strVec.insert(p,s); // p points to.
************* With my compiler (Digital MARS - I have others this is just the one I
happened to be playing with - it coughs on the s != strVec.end() statement. I think
this is because the statement should read: if (p != strVec.end()) .... as the
iterator should be used.
|
Anonymous |
|
Printed |
Page 312
First three lines in Example 8-12, second page |
As is, this code generates malloc errors when run, the reason being that the recursive delete tries
to delete a pointer that is really a pass by reference.
This can be fixed by using
TreeNode<string>* node1 = new TreeNode<string>("frank");
....
node1->addChild(node2);
This problem, however, is something that might merit discussion as it had me confused for a bit.
|
Anonymous |
|
Printed |
Page 355
Function writeTableRow |
Newer versions of gcc (3.4 and above) require "typename" to be inserted before
vector<valT>::const_iterator in the declaration of the for loop.
original:
for (vector<valT>::const_iterator p = v.begin( );
changes to:
for (typename vector<valT>::const_iterator p = v.begin( );
|
Anonymous |
|
Printed |
Page 377
Example 10-14. Creating a temporary filename |
This is in reference to "10.9 Creating a Temporary Filename and File".
The example recommends using the function tmpnam to create a unique file name. Using this function is discouraged. See the man page.
tmpnam -- "Never use this function. Use mkstemp(3) instead."
|
Anonymous |
|
Printed |
Page 377
Example 10-14. Creating a temporary filename |
This is in reference to "10.9 Creating a Temporary Filename and File".
The example recommends using the function tmpnam to create a unique file name. Using this function is discouraged. See the man page.
tmpnam -- "Never use this function. Use mkstemp(3) instead."
|
Anonymous |
Jul 23, 2008 |
Printed |
Page 405
Last paragraph (program output) |
Neither Mathematica nor 'R' agree with the given values for variance.
In order to obtain agreement with the value given by these packages (4454/3), the divisor cnt in the nthMoment function on page 404 would need to be replaced by cnt-1.
|
Anonymous |
Aug 01, 2012 |
Printed |
Page 405
Last paragraph (program output) |
Neither Mathematica nor 'R' agree with the given values for variance.
In order to obtain agreement with the value given by these packages (4454/3), the divisor cnt in the nthMoment function on page 404 would need to be replaced by cnt-1.
|
Anonymous |
Aug 01, 2012 |
Printed |
Page 423
Under //constructors paragraph |
TEXT IS:
explicit matrix(const valarray<T>& x)
SHOULD BE:
explicit matrix(const std::valarray<T>& x)
|
Anonymous |
Aug 19, 2009 |
Printed |
Page 429
Heading, Problem, Solution |
'Matricies' should be spelled 'matrices'. Misspelled in several places and in TOC (pg. ix).
|
Anonymous |
|
Printed |
Page 431
Code for bitReverse funtion |
Integer mask is assigned a value , but is never used.
Program does not produce output stated.
|
Anonymous |
Jan 31, 2010 |
Printed |
Page 461
paragraphs 1-3 |
In third paragraph:
"So what actually happens when submitJob calls notify_all is that the waiting
thread..." submitJob does not call notify_all in the example code. It calls notify_one.
Also, paragraphs 1-3 are in need of major editing. I have read this section at least 10 times and I
am still not sure I understand what the author is explaining.
|
Anonymous |
|
Printed |
Page 462
Example 12-5 |
The variable declaration "init_" in the struct Conn:
static boost::once_flag init_
should be
static boost::once_flag initFlag_
as per the description and discussion on page 463 after the second paragraph.
Similarly the starting values should be set to the correct name:
boost::once_flag Conn::initFlag_ = BOOST_ONCE_INIT;
and the call inside the worker function should be:
boost::call_once(Conn::init, Conn::initFlag_);
It would be easier just to change the discussion on page 463, but from the discussion it's clear that "initFlag_" is a better name than "init_".
|
Oliver Sampson |
Mar 27, 2011 |
Printed |
Page 500
Line 9 |
Characters callback function is now -
void characters(const XMLCh* const chars, const XMLSize_t length)
for Xerces 3.1.1
|
Anonymous |
Jul 19, 2011 |
Printed |
Page 500
Example 14-7 |
SAX2 ErrorHandler requires -
using namespace xercesc;
|
Anonymous |
Jul 19, 2011 |
PDF |
Page 516
Discussion, 2nd paragraph |
"The purpose of DTDs is to identify the subset of well-formed XML documents that are interesting in a certain application domain."
This is wrong, well-formedness (i.e. if an XML instance is syntactically correct) can be checked without any document grammar since well-formedness is a part of the XML specification. However, validity can only be checked with a grammar such as a DTD or an XSD at hand.
The same mistake is on page 520, Discussion, 1st paragraph:
"The purpose of a schema is to identify the subset of well-formed XML documents that are interesting in a certain application domain."
|
Anonymous |
Jun 14, 2012 |
Printed |
Page 534
Example 14-26 |
The example is "Adding support for serialization to the class Animal...", but the
example code shows "class Contact".
The code should be "class Animal"
|
Anonymous |
|
Printed |
Page 541
Example 15-2 source listing |
Initialisation order of ival_,sval_ generates -Wreorder warning in some compilers
Members sval_ and ival_ are private when they should be public. Example will not compile (even with Error line commented out). Fix is to move declarations to public: section.
|
Andrew Ircha |
Dec 12, 2017 |