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

📄 errata.html

📁 著名的Accelerated C++电子书及其源代码
💻 HTML
📖 第 1 页 / 共 2 页
字号:
Page 135: In the last line of the first paragraph of section 7.4.4,
<tt>&lt;</tt> should be <tt>&lt;=</tt>.
</li><li>
Page 190, last line on the page:  <tt>vector</tt> should be <tt>Vec</tt>.
</li><li>
Page 204, code example: The second parameter for <tt>construct</tt> should be
<tt>const</tt> <tt>T&amp;</tt>, not <tt>T</tt>.
</li><li>
Page 205, the declarations of <tt>uninitialized_copy</tt> and <tt>uninitialized_fill</tt>
should be
<ul><tt>
template&lt;class In, class Out&gt; Out uninitialized_copy(In, In, Out);
<br>
template&lt;class Out, class T&gt; void uninitialized_fill(Out, Out, const T&amp;);
</tt></ul>
where <tt>In</tt> is an input-iterator type and
<tt>Out</tt> is a forward-iterator type.
</li><li>
Page 213, just after the last code example:  The second sentence should
say ``The first statement defines <tt>t</tt>...'' instead of referring to <tt>s</tt>.
</li><li>
Page 257, two lines before the beginning of section 14.1.2:
<tt>student.grade()</tt> should be <tt>(*student).grade()</tt>.
</li><li>
Page 283, last example: The <tt>width</tt> function
should call <tt>std::max</tt> explicitly instead of plain <tt>max</tt>.
</li><li>
Page 284, last example: The <tt>height</tt> function
should call <tt>std::max</tt> explicitly instead of plain <tt>max</tt>.
</li>
<li>
Page 330, the index entry for <tt>http://www.accu.org</tt> should refer to
page 294 (where the URL actually appears) rather than page 293
(where the section begins that contains the URL).
</li>
<li>
Page 307: Near the bottom 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></ul>

<h2>Clarifications in the second printing</h2>
<ul>
<li>
Page 44 uses the term ``(one past)'' without explaining it.
The idea is that if <tt>c</tt> is a container, <tt>c.end()</tt> does not
refer to the last element, but rather to the imaginary location where
the element after the last one would be if it existed.
</li><li>
Page 76, last paragraph before section 5.1.1: The text should make it clear
that assigning a new value to <tt>students</tt> overwrites the previous contents.
</li><li>
Page 103, immediately after the first example: ``third argument is an iterator''
is clearer if replaced by ``third parameter is required to be an iterator''.
</li><li>
Page 107, just after the last example:  It is clearer to say that
<tt>static</tt> local variables are ``constructed'' than that they are ``created,''
because the storage that the variable occupies is supposed to be allocated
when the program begins execution.
</li><li>
Page 135: The explanation of <tt>nrand</tt> could be clearer.
</li><li>
Page 142: The second paragraph of section 8.1.2 could be clearer.
</li><li>
Page 151: The description of <tt>ostream_iterator</tt> does not make it clear
that the second argument must have type <tt>const</tt> <tt>char*</tt>.
In particular, it cannot be a <tt>string</tt> or a character literal.
</li><li>
Page 154: In exercise 8-2, <tt>equal(b,</tt> <tt>e,</tt> <tt>d)</tt>
would be clearer as <tt>equal(b,</tt> <tt>e,</tt> <tt>b2)</tt>.
</li><li>
Page 195, just before the last code example: It should be clearer that
we are referring to the copy constructor, as opposed to other constructors.
</li><li>
Page 201, second paragraph of section 11.3.5: The second sentence
should be clearer.
</li><li>
Page 202, last line before the example: the word ``copy'' is ambiguous.


</li></ul>


<h2>Typographical details in the second printing</h2>
<ul>
<li>
In various places, <tt>container&lt;T&gt;</tt> should really appear as
<em>container</em><tt>&lt;T&gt;</tt> because there is no standard type named
<tt>container</tt>; instead, <em>container</em> refers to the name of any
standard-library container class.
</li><li>
Page 11: The second-to-last paragraph in the section just before 1.2
should have ``Our'' instead of ``Out'' as its first word.
</li><li>
Page 21: In the line just before the code example, ``what know''
should be ``what we know''.
</li><li>
Page 45, second paragraph before the diagram, ``average of value'' in the
last line of that paragraph should be ``average value''.
</li><li>
Page 51: In the seventh line from the bottom, the word ``same'' appears twice in succession.
</li><li>
Page 66: In the fourth line from the bottom, the word ``about''
appears twice in a row.
</li><li>
Page 104: It is useful for the first paragraph to include a reference back to page 88.
</li><li>
Page 139: In the penultimate line, ``constrains'' should be ``constrain.''
</li><li>
Page 152: The penultimate comment in the first code example is in the wrong font.
</li><li>
Page 250, three lines before the last code example: ``(<tt>publicly</tt>)''
should be ``(<tt>public</tt>ly)''.
</li></ul>

<h2>Technical errors in the first printing</h2>
<ul>
<li>
The calls to <tt>setw</tt>, such as the one near the bottom of page
64, do not work as advertised.
The implementations that we used do not implement <tt>setw</tt>
properly for <tt>string</tt>s, as we noted in exercise 4-9 (page 74),
so we did not discover the problem during testing.
<p>
The most straightforward solution is to replace
</p><ul><tt>
cout &lt;&lt; setw(maxlen+1) &lt;&lt; students[i].name;
</tt></ul>
by
<ul><tt>
cout &lt;&lt; students[i].name &lt;&lt; string(maxlen+1 - students[i].name.size(), ' ');
</tt></ul>
thereby obviating exercise 4.9 entirely.
Alternatively, one could write
<ul><tt>cout &lt;&lt; setw(maxlen+1) &lt;&lt;
setiosflags(ios_base::left) &lt;&lt; students[i].name &lt;&lt;
resetiosflags(ios_base::left);
</tt></ul>
which would cause <tt>cout</tt> to left-justify (i.e. pad on the right)
while writing <tt>students[i].name</tt>.
</li><li>
Page 32: The definition of <tt>%</tt> in the table should say <tt>x - ((x / y) * y)</tt>
instead of <tt>x - ((x - y) * y)</tt>.  Ditto for the table on page 307.
</li><li>
Page 35: The using-directive for <tt>std::precision</tt> shouldn't be there.
</li><li>
Page 36: The program might divide by zero if the student enters no grades.
Discussing this eventuality in the main text would be a diversion, so we've added
a new exercise.
</li><li>
Page 46: The using-directive for <tt>std::precision</tt> shouldn't be there.
</li><li>
Page 47: The line near the middle of the page reading
<ol><tt>: median = homework[mid];</tt></ol>
should be
<ol><tt>: homework[mid];</tt></ol>
</li><li>
Page 54: The phrase ``reference to <tt>const</tt> <tt>double</tt>'' near the bottom of the page
should be ``reference to <tt>vector</tt> of <tt>const</tt> <tt>double</tt>.''
</li><li>
Page 60: In the program example, the subexpression <tt>grade(students[i])</tt>
should be <tt>grade(midterm,</tt> <tt>final,</tt> <tt>homework)</tt>.
</li><li>
Page 73: The description of the <tt>width</tt> member function should say that
the output is padded on the left, not on the right.
</li><li>
Page 80: In the first code example on the page, <tt>vector&lt;Student::info&gt;</tt>
should be <tt>vector&lt;Student_info&gt;</tt>.
</li><li>
Page 95: The comments in the program on this page have "left-hand"
and "right-hand" reversed.
</li><li>
Page 97: The definition
<tt>container&lt;T&gt;</tt> <tt>c();</tt>
should be
<tt>container&lt;T&gt;</tt> <tt>c;</tt>
</li><li>
Page 108: The test for <tt>i</tt> + <tt>sep.size()</tt> <tt>!=</tt> <tt>e</tt>
in the inner <tt>if</tt> is redundant,
as is the test <tt>if</tt> <tt>(i</tt> <tt>!=</tt> <tt>e)</tt> near the end of the program.
</li><li>
Page 115: In the last line of section 6.2.3, <tt>median_grade</tt> should be
<tt>grade_aux</tt>.
The <tt>average_analysis</tt> function does not take into account the possibility that
a student did no homework at all.
We're going to leave that possibility as an exercise.
</li><li>
Page 121: The description of <tt>accumulate</tt> is wrong.
The function copies <tt>t</tt>, adds each element in the range <tt>[b,</tt> <tt>e)</tt>
to the copy of <tt>t</tt>, and returns a copy of the modified copy of <tt>t</tt>
as its result.
</li>
<li>
Page 147: In the first paragraph in 8.2.4, it isn't really true that forward
iterators prevent us from looking at an element again.
What they do is to prevent us from moving an iterator to the
immediately preceding element.
</li>
<li>
Page 150: In the first sentence of section 8.3, the phrase "separate categories
from output iterators" should be "separate categories from forward iterators."
</li><li>
Page 163: In the last paragraph, the claim that users don't need to know
how <tt>Student_info</tt> is implemented isn't quite accurate:
They don't need to know in order to write code that uses it,
but they do need to know some of the details
in order to be able to prepare input files for the program.
</li><li>
Page 176: The <tt>month_lengths</tt> array should be defined as
<ul><tt>
const int month_lengths[] = { /* ... */ };
</tt></ul>
</li><li>
Page 178: The <tt>letters</tt> array should be defined as
<br>
<tt>
static const char* const letters[] = { /* ... */ };
</tt>
<br>
because there is no intent ever to change its elements.
</li><li>
Page 195: The call to <tt>split(words)</tt> in the last line of the
first code example should be <tt>split(line)</tt>.
</li><li>
Page 199: The name <tt>blanks</tt> should be <tt>spaces</tt>.
</li><li>
Page 200: The two references to <tt>words</tt> in the first complete
paragraph (the second of which is in a code example) should refer to <tt>line</tt>.
</li><li>
Page 220: In the last example on the page,
the variables <tt>temp</tt> and <tt>s</tt>
should be <tt>temp1</tt> and <tt>greeting</tt>, respectively.
</li><li>
Page 221: In the second paragraph of section 12.4, we should be talking about
<tt>Vec</tt>, not <tt>vector</tt>.
Moreover, in the hypothetical case, <tt>p</tt> would contain 42 empty rows,
not 42 rows of single null characters.
</li><li>
Page 249: Just before the last example, the phrase "version of <tt>final</tt> in <tt>Core</tt>"
should be "version of <tt>regrade</tt> in <tt>Core</tt>."
</li><li>
Page 250: Near the end of the third line, <tt>final</tt> should be <tt>regrade</tt>.
</li><li>
Page 264: In the first example, the last comment should say
"<em>changes only </em><tt>s2</tt><em> and not </em><tt>s1</tt>" instead of
"<em>changes only </em><tt>s1</tt><em> and not </em><tt>s2</tt>."
In the following example, the call <tt>make_unique();</tt> should be
<tt>cp.make_unique();</tt>
Page 281: in the last line before section 15.2.2, <tt>operator&gt;&gt;</tt> should be <tt>operator&lt;&lt;</tt>.
</li><li>
Page 282: In the last example, the last two parameters should be named
<tt>beg</tt> and <tt>end</tt>, respectively.
</li><li>
Page 287: In the discussion near the bottom of the page, <tt>protected</tt>
allows access to the base-class part of any object of the appropriate derived class,
not just the base-class part of the current object.
What it does not allow is access to members of freestanding base-class objects.
</li><li>
Page 292: Just before the sample output, the text describes the grade histogram as
containing asterisks, when it actually contains <tt>=</tt> symbols.
</li></ul>

<h2>Clarifications in the first printing</h2>
<ul>
<li>
Page 28: The description of the <tt>for</tt> statement should make it clear that
the <em>init-statement</em> is required to be either a definition or an
expression statement.
</li><li>
Page 191: In the first complete paragraph, the two uses of <tt>size_t</tt>
are easier to understand if they refer to <tt>size_type</tt> instead, to match the code.
The two names refer to the same type, so the uses are technically correct,
but it's easier to understand if they're changed.
</li><li>
Page 193: The discussion of the <tt>size</tt> function
at the bottom of the page makes it appear that the type
of the difference between two pointers is more important
than it really is.
The real point is that although the value of <tt>limit</tt> <tt>-</tt> <tt>data</tt>
has type <tt>ptrdiff_t</tt>, returning that value from <tt>size</tt>
converts it to <tt>size</tt>'s return type.
</li></ul>

<h2>Typographical details in the first printing</h2>
<ul>
<li>
If a page has any <tt>constant-width</tt> text in the heading at the
top of the page (which can happen only for odd-numbered pages), the
page number is very slightly smaller than it should be.
The affected page numbers are 3, 85, 87, 89, 91, 93, 95, 103, 105,
107, 109, 163, 179, 189, 191, 193, 215, 217, 219, 233, and 235.
</li>
<li>
Page xii: "language" should be "language" near the end of the third paragraph.
</li>
<li>
Page 24: Shortly before 2.4.1.2, change "such the ones" to "such as the ones."
</li><li>
Page 30: Change <tt>string::size_type</tt> to <tt>int</tt> in the two
<tt>for</tt> statements at the bottom of the page.
</li><li>
Page 34: The program in exercise 2-10 should have a
<tt>return 0;</tt> statement at the end.
</li><li>
Page 45: Near the bottom, change "it should easy" to "it should be easy."
</li><li>
Page 72: The comments in the last example on the page have their
beginning slashes in italic font rather than constant-width font.
</li><li>
Page 158: The word "have" appears twice in a row in the first paragraph
after the numbered list near the top of the page.
</li><li>
Page 162: The word "the" appears twice in a row in the first complete paragraph
on this page.
</li><li>
Page 164: The word "be" appears twice in a row in paragraph 5, line 3.
</li>
<li>
Page 167: In the second line of the paragraph beginning "<strong>Protection labels</strong>,"
"accessible" should be "accessible."
</li>
<li>
Page 178: In the second complete paragraph from the end of the page,
"determine the its type" should be "determine its type."
</li><li>
Page 199: Immediately before the example, "in of an expression" should be "in an expression."
In the last complete paragraph, the word "the" appears twice in a row.
</li><li>
Page 203: On the first line of the page, "such this one" should be "such as this one."
</li><li>
Page 224: Near the middle of the page, "does not to prevent" should be
"does not prevent."
</li><li>
Page 253: Near the end of the second paragraph, "use the a single" should be
"use a single."
</li><li>
Page 260: In the first line of the first complete paragraph,
"we would like be able" should be "we would like to be able."
</li><li>
Page 262: In the second paragraph from the end, ``such <tt>Student_info</tt>''
should be ``such as <tt>Student_info</tt>.''
</li><li>
Page 283: In the first complete paragraph, "an ordinary member functions"
should be "an ordinary member function."
</li><li>
Page 289: In the fourth line, "parameter, type" should be "parameter type."
</li><li>
Page 307: The table extends beyond the nominal right margin.
</li></ul>
<div class="prevnext">
<a href="109.htm"><img src="images/Prev1.gif" />
</div>
</body>
</html>

⌨️ 快捷键说明

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