⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 errata.html

📁 著名的Accelerated C++电子书及其源代码
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Accelerated C++ Errata</title>
<link rel="stylesheet" type="text/css" href="./acc.css" />
</head>

<body>
<div class="prevnext">
<a href="109.htm"><img src="images/Prev1.gif" /></a>
</div>
<h1>Accelerated C++ Errata</h1>

<em>Last modified 23 September 2004.</em>
<p>

Every book has bugs in it, and <cite>Accelerated C++</cite> is
no
exception.
This page notes the bugs that have come to our attention,
and the printings in which they were discovered.
All of these errors are corrected in the printing after the one in
which they were found, except that errors noted in the fifth printing
were not corrected until the ninth printing, which went to press in
August, 2004.
</p>
<p>
Please note that because of corrections, page numbers may sometimes
differ slightly from one printing to another.
So, for example, if you have a copy of the first printing, and you are
looking for a correction first noticed in the fourth printing,
you may find it on the page before or after the one cited.
</p>
<p>
Thanks to
Walter&nbsp;E.&nbsp;Brown,
Don&nbsp;Caldwell, Paolo&nbsp;Carlini,
Neil&nbsp;Cerutti, Harry&nbsp;Chung, David&nbsp;Clark, Anton&nbsp;Doblmaier,
Debatosh&nbsp;Debnath, Steven&nbsp;van&nbsp;Dijk, Hans&nbsp;Dulimarta, Daniel&nbsp;Faber,
Attila&nbsp;Feher, Adam&nbsp;Foster, Kevin&nbsp;Goodsell,
Seyed&nbsp;H.&nbsp;Haeri, Gregory&nbsp;Haley, Mogens&nbsp;Hansen,
Philip&nbsp;Hibbs, Anto&nbsp;Jurkovic,
John&nbsp;Linderman, Greg&nbsp;McClure, Miguel&nbsp;Mart韓ez de&nbsp;la&nbsp;Torre,
Bernd&nbsp;Mohr, Wo-Yip&nbsp;Ng, Nicole&nbsp;McAllister,
Brian&nbsp;McNamara, Frank&nbsp;Mittelbach, Ron&nbsp;Natalie, John&nbsp;Potter,
Peter&nbsp;N.&nbsp;Roth, Andreas&nbsp;Scherer, William&nbsp;Simon,
Marc&nbsp;Souaille, Randy&nbsp;Sherman, Ralf&nbsp;Taner,
Antoine&nbsp;Trux, Alex&nbsp;Tuzlukov, Abraham&nbsp;Walfish,
Conrad&nbsp;Weisert, and Han&nbsp;Xu
for pointing&nbsp;them&nbsp;out!

</p><h2>Technical errors in the fifth printing</h2>
<ul>
<li>
Pages 32 and 307: The precedence table should say that the assignment and conditional
operators have the same precedence and are right-associative.
</li><li>
Page 173: In the second line from the end of the page,
<tt>*beg</tt> should be <tt>*begin</tt> (twice).
</li><li>
Page 179: The text should say that it is possible for <tt>argc</tt>to be zero.
</li><li>
Pages 191-192, 314: The types that containers are required to provide
include <tt>difference_type</tt>
</li><li>
Page 223: In the fourth line of the first complete paragraph,
<tt>iostream</tt> should be <tt>istream</tt>.
</li><li>
Page 224: In the fifth line after the second program example,
<tt>string</tt> should be <tt>Str</tt>.
</li><li>
Page 304: The text incorrectly states that <tt>float</tt> is promoted
to <tt>double</tt> as part of the standard arithmetic conversions.
</li></ul>

<h2>Clarifications in the fifth printing</h2>
<ul>
<li>
Page 24: The discussion at the bottom of the page should say explicitly
that treating a <tt>bool</tt> value as a number yields <tt>1</tt> if the
<tt>bool</tt> is <tt>true</tt> and<tt>0</tt> if the <tt>bool</tt> is <tt>false</tt>.
</li><li>
Page 216: In the code example at the bottom of the page, the call to
<tt>s.data.push_back</tt> is not the only compile error, because it is not
the only reference to <tt>s.data</tt>; there is another reference near the
beginning of the example.
</li></ul>

<h2>Typographical details in the fifth printing</h2>
<ul>
<li>
Page 57: In the fourth paragraph, the first sentence should end with
``end-of-file'' instead of ``end-of file.''
</li><li>
Page 111: In the last full paragraph, the variable named <tt>didn't</tt>
should be <tt>didnt</tt>.
</li><li>
Page 128: Near the bottom of the page, the sentence that refers to
``the data structure that <tt>split</tt> returns'' should instead
be referring to <tt>xref</tt>.
</li><li>
Page 154: There is a comma missing in the argument list of the call
to <tt>copy</tt> in the last line of exercise 8-6.
</li><li>
Page 219: The constructor of class <tt>Str</tt> should have parameters
named <tt>b</tt> and <tt>e</tt>, rather than <tt>i</tt> and <tt>j</tt>,
to match the version on page 212.
</li></ul>

<h2>Technical errors in the fourth printing</h2>
<ul>
<li>
Page 34: In exercise 2-10, the comparison <tt>k</tt> <tt>!=</tt> <tt>n</tt>
should be <tt>k</tt> <tt>!=</tt> <tt>10</tt>.
</li><li>
Page 70: The invariant near the bottom of the page should refer to
<tt>maxlen</tt> rather than <tt>max</tt>.
</li><li>
Page 174: In the third line from the bottom, <tt>coord</tt> <tt>+</tt> <tt>1</tt>
should be <tt>coords</tt> <tt>+</tt> <tt>1</tt>.
</li><li>
Page 183: In the comment in the code example near the bottom of the page,
<tt>p</tt> should be <tt>*p</tt>.
</li><li>
Page 190: In the last code example on the page, <tt>size_type</tt>
should be <tt>std::size_t</tt>.
Note that the similar example on page 193 is correct as it stands,
because <tt>size_type</tt> has now been defined.
</li><li>
Page 239: The call to <tt>students[i].grade()</tt> is dynamically bound,
not statically bound.  However, because the type of <tt>students[i]</tt> is known
during compilation, the effect is the same as that of static binding.
</li><li>
Page 264: The first code example should call <tt>s1.read(cin)</tt>
rather than <tt>read(cin,</tt> <tt>s1)</tt>, and similarly for <tt>s2</tt>.
</li><li>
Pages 265-266: The text sometimes mentions the standard <tt>vector</tt> class
when it should refer to the <tt>Vec</tt> class that we are defining.
</li><li>
Page 280: The last code example has a spurious semicolon at the end.
</li><li>
Page 281: The first complete paragraph should note that <tt>Pic</tt>
must also be a friend.
</li><li>
Page 304: The list of conversions is missing an entry, just before the last one.
It should say: ``Otherwise, if either operand is <tt>unsigned</tt> <tt>int</tt>,
the result is <tt>unsigned</tt> <tt>int</tt>.''
It also needs to mention the integral promotions.
</li><li>
Page 307: The description of compound assignment should say
<tt>x</tt> <em>op</em><tt>=</tt> <tt>y</tt>
instead of
<tt>x</tt> <em>op</em><tt>=</tt> <tt>x</tt>
</li></ul>

<h2>Typographical details in the fourth printing</h2>
<ul>
The code examples are not consistent about whether to put a space
after <tt>template</tt>; that is, whether to say
<ol><tt>template&lt;class T&gt; class Vec { /* ... */ };</tt></ol>
or
<ol><tt>template &lt;class T&gt; class Vec { /* ... */ };</tt></ol>

Fortunately, it's correct either way.
</ul>

<h2>Clarifications in the fourth printing</h2>
<ul>
<li>
Pages 32 and 307: The description of compound assignments in the table should enumerate the
operators explicitly.
The description of <tt>%</tt> should say that the operands must be integers.
</li><li>
Page 100: In exercise 5-9, it's not clear whether a word containing mixed-case
letters is uppercase or lowercase.
The exercise should be to write all the words in the input that do not contain
any uppercase letters, followed by all the words that contain one or more uppercase letters.
</li><li>
Page 179: The program at the bottom of the page can be made easier to understand
by writing <tt>argv[1]</tt> as a special case, and then printing a space
<em>before</em> each subsequent argument, if any.
</li><li>
Pages 260 and 263: The initializations of <tt>p</tt> and <tt>refptr</tt>
are clearer if they appear in the same order as the definitions of the
data members themselves.
</li></ul>


<h2>Technical errors in the third printing</h2>
<ul>
<li>
Page 47: The invariant in the comment on the third line of the page
should say that <tt>homework</tt> contains all the homework grades read
so far, rather than all the grades.
Similarly for the invariant in the comment near the bottom of page 70.
</li><li>
Page 100: In exercise 5-6, <tt>v</tt> should be <tt>students</tt> throughout.
</li><li>
Page 136: In the first complete paragraph on the page, the third sentence should
refer to ``the body'' rather than ``the <tt>push_back</tt>.''
</li><li>
Pages 167, 238, 241, 248, and 258: <tt>students.name.size()</tt>
should be <tt>students.name().size()</tt> instead.
</li><li>
Page 186: <tt>&lt;ifstream&gt;</tt> should be <tt>&lt;fstream&gt;</tt>
</li><li>
Page 191: Containers need to define <tt>reference</tt> and <tt>const_reference</tt>
as well as <tt>value_type</tt>.
</li><li>
Page 203: In the last paragraph before the code example,
<tt>size</tt> and <tt>end</tt> need to know about the new member
as well.
</li><li>
Page 206: The comments in the code example should reflect that the
definitions of <tt>size</tt> and <tt>end</tt> are changed.
</li><li>
Page 209: The last sentence of the second paragraph swaps the descriptions of
<tt>limit</tt> and <tt>avail</tt>.
</li><li>
Page 213: On the third line of the first code example, the comment
should refer to <tt>d2</tt> instead of <tt>d</tt>.
</li><li>
Page 222: The declaration of <tt>operator</tt> <tt>double</tt> in the
first code example should have a <tt>const</tt> immediately before the semicolon.
</li><li>
Pages 258 and 259: In the example that spans those pages,
<tt>runtime_error</tt> should be <tt>std::runtime_error</tt>.
</li><li>
Pages 261 and 263:  The definition of <tt>refptr</tt> should mention
<tt>std::size_t</tt> rather than <tt>size_t</tt>.
</li><li>
Page 264:  In the last example before the start of section 14.4,
<tt>run_time_error</tt> should be <tt>runtime_error</tt>.
</li><li>
Pages 271, 273, and 276: Class <tt>Pic_base</tt> should have an empty virtual destructor.
</li><li>
Page 277: In the sentence before the last code example,
<tt>vector&lt;char&gt;</tt> should be <tt>vector&lt;string&gt;</tt>.
</li><li>
Page 281: The second code example should refer to <tt>std::max</tt>
rather than just <tt>max</tt>.
</li></ul>

<h2>Clarifications in the third printing</h2>
<ul>
<li>
Page 28: It should be explicit that we are talking about the values
that <tt>r</tt> takes on in the loop bodies, not what value it
might have after the loop completes.
</li><li>
Page 73: Exercise 4-6 should ask the reader to rewrite the
<tt>read</tt> and <tt>grade</tt> functions as well as the
<tt>Student_info</tt> structure.
</li><li>
Page 154: The <tt>xref</tt> function doesn't return a <tt>vector&lt;string&gt;</tt>,
so exercise 8-5 should describe the current behavior as ``placing their entire
output in a data structure.''
</li><li>
Page 165: The discussion at the bottom of the page should say explicitly
that initialization takes place in the order of declaration, not in
the order of the member-initializer list.
</li><li>
Page 184: The discussion of off-the-end pointers in the third paragraph
of 10.6.2 should refer to the earlier discussion on page 149.
</li><li>
Page 190: The comments in the first example should make it clear that
the definitions use the cited constructors, rather than defining them.
</li><li>
Page 191: In section 11.2.3, paragraph 2, the first sentence refers
to ``the type of the objects that the container stores.''
It is clearer to refer to ``the type of each object that the container stores.''
</li><li>
Page 258: In order to use the <tt>Handle</tt> class, it is necessary to
change the Core class to allow <tt>Handle&lt;core&gt;</tt> to use the <tt>clone</tt>
member, either by making <tt>Handle&lt;core&gt;</tt> a friend of <tt>Core</tt>
or by making the <tt>clone</tt> member <tt>public</tt>.
</li><li>
Page 306: The description of operators that guarantee order of
evaluation should include the comma operator (correctly described at the
bottom of the table on page 307).
</li></ul>

<h2>Typographical details in the third printing</h2>
<ul>
<li>
Page 128: In the penultimate comment in the code example,
``lines numbers'' should be ``line numbers.''
</li><li>
Page 164: The last line of the fourth paragraph has an extra word ``a'' in it.
</li><li>
Page 192: In the last line of the page, ``It the operator...'' should be
``If the operator...''
</li><li>
Page 247: There should not be a space between ``<tt>friend</tt>''
and ``ship'' at the end of the first complete paragraph.
</li><li>
Pages 292 and 294: The chapter title at the top of the page is missing
a question mark.
</li><li>
Page 296: In the paragraph beginning ``C++ inherits its'' near the
middle of the page, there is a missing word ``by'' after ``followed''
in the third line.
</li><li>
Page 297: The first line of the definition of <em>type-specifier</em> should end with an
``or'' (|) symbol.
</li><li>
Page 303: The word ``is'' appears twice in a row in section A.2.3,
paragraph 2, line 1.
</li></ul>

<h2>Technical errors in the second printing</h2>
<ul>
<li>
Page 22, first paragraph, last line: ``true'' should be ``false''
</li><li>
Page 32, near the end of the table: <tt>x</tt> <em>op</em><tt>=</tt> <tt>x</tt>
should be <tt>x</tt> <em>op</em><tt>=</tt> <tt>y</tt>.
</li><li>
Page 33: The equivalence between <tt>for</tt> and <tt>while</tt> statements
is not exact if the <em>statement</em> is or contains a <tt>continue</tt> statement.
</li><li>
Page 34: In the description
<ol><tt>if (</tt><em>&lt;condition&gt;</em><tt>) </tt><em>statement</em><tt>; else </tt><em>statement2</em></ol>
there should be no semicolon, because the <em>statement</em> will usually have
one of its own.
</li><li>
Page 48, just before 3.3: The execution time of <tt>sort</tt> is guaranteed in
the average case, but it is possible for it to run more slowly with
pathological input.
</li><li>
Page 64: The 11th line from the bottom is missing some characters:
<ol><tt>&lt;&lt; string(maxlen + 1 - students[i].name.size(), '</tt></ol>
should be
<ol><tt>&lt;&lt; string(maxlen + 1 - students[i].name.size(), ' ');</tt></ol>
</li><li>
Page 70, 7 lines from the bottom:
<tt>vs</tt> should be <tt>students</tt> in the comment on that line.
</li><li>
Page 97: <tt>erase</tt> returns an iterator referring to the position
immediately after the erasure.
<tt>c[n]</tt> refers to a container element, not necessarily a character.
</li><li>
Page 116, two paragraphs before the beginning of section 6.3:
The first reference to <tt>v</tt> in that paragraph should refer to
<tt>s.homework</tt> instead, as should the reference to <tt>v</tt>
in the comment in the code example.
The last two references to
should refer to <tt>nonzero</tt> instead.
</li><li>
Page 120: The last code example should call <tt>students.erase</tt>,
not <tt>v.erase</tt>.
</li><li>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -