Errata for The C++ Standard Library From Scratch
This page lists errors in the book and clarifications of ambiguous points.
If you think you have found another error if you have other questions about
the book, please contact the author at
Pablo Halpern <email@example.com>. Please include
your full name so that I can credit you for finding the error. For additional
book-related support, check out my support page.
Last updated 05/19/2003
Attention Microsoft Visual C++ Users:
At the time The C++ Standard Library From Scratch was written,
Visual C++ version 6.0 was the the most current compiler from Microsoft. The book and examples
have numerous work-arounds for compiler and library bugs in VC++ 6.0 that are no longer
necessary in the newer VC++ 7.0 (aka VC++.NET). Please not the following important points:
Visual C++ 6.0 users: Although it is mentioned in the introduction,
it is worth repeating here that the library that shipped with VC++ 6.0 had some
significant bugs. To get the latest bug fixes, you must do two things:
- Go the the Microsoft Web site and download any service packs for the compiler.
- Go to http://www.dinkumware.com/vc_fixes.html
and apply the fixes listed there, especially the
<istream> fix. Failing to do this will cause the example code to behave strangely.
Visual C++ 7.0 (.NET) users: throughout the example code there
are conditionals of the form #ifdef _MSC_VER that should
no longer be used for the newer compiler. The best solution is to change each of
these conditionals to #if defined(_MSC_VER) && _MSC_VER < 1300.
Beginning with Chapter 8, this change is crucial to prevent infinite recursion and
stack overflow. Thanks to Stephen Goodman for doing the detective work on this.
Page 7, under What Tools Do I Need?, first paragraph, last sentence:
The exercises are not scattered throughout the book but are available on
the support web site.
Page 8, first paragraph (continued from previous page) describes how to
obtain the egcs 1.1.2 compiler. The egcs compiler has been improved and
re-integrated with the Gnu compiler and is now known as the Gnu Compiler
Collection (GCC) 2.95. You should probably use GCC 3.3 instead of egcs
1.1.2. However, as of 19 May 2003, the examples and exercises have not
been tested with GCC 3.3. Many work-arounds are no longer needed. In particular,
the <sstream> work-around included in the example sources is not needed with
with GCC 3.3. See, also, the README.txt
file that comes with the code.
- Did I mention that you need to go to the Dinkumware web site,
if you use VC++ 6.0? Read the big warning text in orange above.
- The correct email address to reach me is:
Page 18, Figure 1.2: The arrow heads pointing to Address and Appointment
should have asterisks next to them, indicating a one-to-many aggregation.
A portion of this diagram is drawn correctly in Figure 3.1, page 63. Thanks
to John Bell for pointing out this omission.
Page 18 clarification: In the second-to-last paragraph, 5th sentence, "The
top section is the class name, ..." would be clearer if it said "The top
section of each box contains the class name, ...". That is, top,
middle, and bottom refer to each box, not to the whole diagram.
Furthermore I should point out that what looks like double lines in Figure
1.2 are actually two separate lines bracketing an empty section in the
box. Thanks to Mark Chariton for pointing out this lack of clarity.
Page 38, Listing 2.6, line 9: the word "The" will actually show up as "eThe"
if you run the program. A copy editor fixed the "spelling error" at the
last minute, not realizing that it was supposed to be that way.
Page 44, Listing 2.10, line 6 should read "using std::strcpy; using
Page 55, second-to-last sentence. "Listing 2.17 is an attempt to do the
same thing as Listing 2.15, ..." should read "... do the same thing as
Listing 2.16, ...". Thanks to Mark Chariton
Page 65, Listing 3.4, Line 1: The file name is AddressBook.h,
Page 68, Figure 3.2: In the left-middle part of the diagram, the words
should be mytmplt<int>.
Page 68, Listing 3.6: Line 1: The file name is missing. It should say "File
Page 68, Listing 3.6: Line 3: #ifndef should be #ifdef
Pages 86-88, Listings 4.5 - 4.8: Every occurance of the word, addrlist,
in these listings should be replaced by std::list<Address>.
The addrlist typedef is not introduced until Listing 4.9. Thanks
Page 99, Listing 4.6 (continued from previous page), line 67 should be
a blank line (except for the line number). The word "output" was accidentally
inserted during production.
Microsoft Visual C++ users take note: If the input to
the editor always seems to be a line behind (i.e., nothing happens
until you press return twice), then you have a version of the
VC++ library with a number of known bugs. I mentioned this in the
introduction, but many people seemed to have missed it. Dinkumware,
Ltd., the company that supplies the library to Microsoft, has fixed
many of these bugs. A list of fixes is available on the Internet at
http://www.dinkumware.com/vc_fixes.html. You can also purchase a
complete, updated library through this Web site.
Page 157, Figure 6.2, The first column heading should read addrById_,
not addrByName_. Thanks to Mark Chariton
Page 172, Listing 7.1 (continued), line 69, the word cachedLast_
should be changed to cachedFirst_ in the comment. The same change
should be made on page 178, Listing 7.3, line 71. Thanks to Darrin Roberts.
Page 196, Listing 7.9 (continued), Line 127:
127: while (iter !=
Should be replaced with:
127: while (*iter <
*endIter) // empty loop if *endIter absent
This change prevents a potential endless loop if the user edits
a record such that it is no longer in the search results. This change will
not prevent the item from showing up in the list, but it will prevent the
Page 207, The second to last sentence in the Excursion should begin "We
call pop ...," not "We call top..."
Page 208, Listing 8.3, line 6, __GCC__ should be replaced with
Same change for page 233, Listing 8.17, line 12.
Page 225, first paragraph, second line, "0ñRAND_MAX" should
read "0 - RAND_MAX". Thanks to Kevin Seghetti
Page 226, in the excursion, first paragraph, fourth line, "ostringstream,
ifstream and istrstream" should read, "istringstream,
ifstream and istrstream". Thanks to Kevin Seghetti
Page 232, at the end of the excursion, the code given to remove and delete
all the pointers in a container will not compile. The correct code is as
while (! myset.empty())
myclass* p = *myset.begin();
If the container type is not known or is known to be vector, then the following
is more efficient:
template <class Container>
void deleteAndClear(Container& mycontainer)
// This code works for all standard containers except map and multimap
while (! mycontainer.empty())
Container::iterator i = mycontainer.end();
Container::value_type p = *--i;
The function template above works only for containers with
bi-directional or random-access iteratators (including all of the
standard sequence containers and the set container). Neither of the
above code fragments work unchanged for map or
multimap containers, although the same basic techniques can
be used for maps or multimaps container pointer keys and/or pointer values.