?? walls and mirrors c++ (4th ed_) errata.mht
字號:
Page 407 (Jan. 6, 2005)<BR><BR>The two constructors in =
<CODE>ListNode</CODE>=20
should not end with a semicolon.<BR>
<HR>
Page 414 (Jan. 6, 2005)<BR><BR>Near the bottom of the page, the second =
argument=20
of <CODE>sortedRetrieve</CODE> should be a reference=20
argument:<BR><CODE><B>virtual void</B> sortedRetrieve(<B>int</B> index,=20
ListIndexType<FONT color=3Dred>&</FONT> anItem) <B>const</B></CODE> =
<BR>
<HR>
Page 418 (Jan. 6, 2005)<BR><BR>The two constructors in =
<CODE>ListNode</CODE>=20
should not end with a semicolon.<BR>
<HR>
Pages 420 - 421 (Apr. 23, 2004)<BR><BR>Replace the definition of the =
function=20
<CODE>insert</CODE> with<BR><BR><CODE>template <class T><BR>void=20
List<T>::insert(int index, T newItem)=20
throw(ListIndexOutOfRangeException)<BR>{<BR> int newLength =3D =
getLength() +=20
1;<BR><BR> if ((index < 1) || (index > =
newLength))<BR> =20
throw ListIndexOutOfRangeException(<BR> =20
"ListIndexOutOfRangeException: insert index out of range");=20
<BR> else<BR> { // create new node and place newItem in=20
it<BR> ListNode<T> *newPtr =3D new=20
ListNode<T>;<BR> size =3D newLength;<BR> =20
newPtr->item =3D newItem;<BR><BR> // attach new node to=20
list<BR> if (index =3D=3D 1)<BR> { // insert new =
node at=20
beginning of list<BR> newPtr->next =3D=20
head;<BR> head =3D newPtr;<BR> =20
}<BR> else<BR> { ListNode<T> *prev =3D=20
find(index-1);<BR> // insert new node after=20
node<BR> // to which prev=20
points<BR> newPtr->next =3D=20
prev->next;<BR> prev->next =3D=20
newPtr;<BR> } // end if<BR> } // end if<BR>} // end=20
insert<BR></CODE>
<HR>
Page 424 (Apr. 23, 2004)<BR><BR>The declaration of <CODE>count</CODE> =
should be=20
just before the <CODE>for</CODE> statement, not within it. <BR>
<HR>
Page 428 (Jan. 6, 2005)<BR><BR>The constructor in =
<CODE>ListIterator</CODE>=20
should match its definition of page 429:<BR><CODE>ListIterator(<B><FONT=20
color=3Dred>const</FONT></B> *<FONT color=3Dred>aList</FONT>, ListNode=20
*nodePtr);</CODE><BR>
<HR>
Pages 432 - 433 (Apr. 23, 2004)<BR><BR>In the definition of the function =
<CODE>insert</CODE> at the bottom of page 432,<BR>replace the=20
<CODE>if-else</CODE> statement that compares <CODE>newPtr</CODE> with=20
<CODE>NULL</CODE> <BR>by the statements that are in its =
<CODE>else</CODE>=20
clause.<BR><BR>In the <CODE>return</CODE> statement on page 433,=20
<CODE>this</CODE> should be bold.<BR><BR><FONT color=3Dblue>
<HR>
Chapter 9=20
<HR>
</FONT><BR>page 489 (Apr. 23, 2004)<BR><BR>The third <CODE>for</CODE> =
should be=20
bold.<BR><BR><FONT color=3Dblue>
<HR>
Chapter 10=20
<HR>
</FONT><BR>page 509 (Jan. 6, 2005)<BR><BR><CODE>setRootData</CODE> and=20
<CODE>attachLeft</CODE> should not throw a <CODE>TreeException</CODE> if =
a new=20
node cannot be allocated. Thus, make the following =
changes:<BR><BR>Delete=20
<CODE>throw TreeException</CODE> from <CODE>setRootData</CODE>, =
and<BR>delete=20
its last two comments.<BR><BR>Delete the last comment on the page, and =
change=20
the preceding line to<BR><CODE>// a binary tree. Throws TreeException if =
the</CODE><BR>
<HR>
page 510 (Jan. 6, 2005)<BR><BR><CODE>attachRight</CODE> should not throw =
<CODE>TreeException</CODE> if a new node cannot be allocated. Thus, make =
the=20
following changes:<BR><BR>In <CODE>attachRight</CODE>, change the 2nd =
comment=20
to<BR><CODE>// a binary tree. Throws TreeException if =
the</CODE><BR><BR>and=20
delete the 3rd comment.<BR>
<HR>
page 519 (Jan. 6, 2005)<BR><BR>The first constructor in =
<CODE>TreeNode</CODE>=20
should not end with a semicolon.<BR>
<HR>
page 521 (Jan. 6, 2005)<BR><BR>Near the top of the page, delete=20
<CODE><B>throw</B>(TreeException)</CODE> from=20
<CODE>setRootData</CODE>.<BR><BR>Near the bottom of the page,=20
<CODE>copyTree</CODE> should not throw <CODE>TreeException</CODE>, so =
delete the=20
last sentence in its comments.<BR>
<HR>
page 522 (Apr. 23, 2004)<BR><BR>Delete the <CODE>assert</CODE> statement =
from=20
the constructor at the bottom of the page.<BR>
<HR>
page 523 (Apr. 23, 2004)<BR><BR>Line 2: Delete the <CODE>assert</CODE>=20
statement.<BR><BR>In the definition of the function =
<CODE>setRootData</CODE> at=20
the bottom of the page,<BR><BR>1. Delete the <CODE>throw</CODE> =
clause<BR>2.=20
Delete the <CODE>if</CODE> statement that compares <CODE>root</CODE> =
with=20
<CODE>NULL</CODE>=20
<HR>
page 524 (Apr. 23, 2004)<BR><BR>In the definition of the function=20
<CODE>attachLeft</CODE>,<BR>delete the <CODE>if</CODE> statement that =
compares=20
<CODE>root->leftChildPtr</CODE> with <CODE>NULL</CODE>.<BR><BR>In the =
definition of the function <CODE>attachRight</CODE>,<BR>delete the=20
<CODE>if</CODE> statement that compares <CODE>root->rightChildPtr =
</CODE>with=20
<CODE>NULL</CODE>.<BR>
<HR>
page 524 (Jan. 6, 2005)<BR><BR>Three <CODE>else</CODE> clauses are =
labeled with=20
the comment Assertion. Add <CODE>assert</CODE> statements, as=20
follows:<BR><BR><CODE><B>else</B> // Assertion: nonempty tree; no left=20
child<BR>{<BR> assert(root !=3D NULL &&=20
root->leftChildPtr =3D=3D =
NULL);<BR> root->leftChildPtr =3D=20
<B>new</B> treeNode(newItem, NULL, NULL);<BR>} // end if<BR><BR>. . . . =
. . . .=20
. . . . . . . . . . . . . . . . . . . . . . . . . . . . =
<BR><BR><B>else</B> //=20
Assertion: nonempty tree; no right =
child<BR>{<BR> assert(root=20
!=3D NULL && root->rightChildPtr =3D=3D=20
NULL);<BR> root->rightChildPtr =3D <B>new</B>=20
treeNode(newItem, NULL, NULL);<BR>} // end if<BR><BR>. . . . . . . . . . =
. . . .=20
. . . . . . . . . . . . . . . . . . . . . . <BR><BR><B>else</B> // =
Assertion:=20
nonempty tree; no left child<BR>{<BR> assert(root !=3D =
NULL=20
&& root->leftChildPtr =3D=3D=20
NULL);<BR> root->leftChildPtr =3D=20
leftTree.root;<BR> leftTree.root =3D NULL;<BR>} // end=20
if<BR></CODE>
<HR>
page 525 (Jan. 6, 2005)<BR><BR>In <CODE>attachRightSubtree</CODE> near =
the top=20
of the page, add an <CODE>assert</CODE> statement to the 2nd =
<CODE>else</CODE>=20
clause, as follows:<BR><BR><CODE><B>else</B> // Assertion: nonempty =
tree; no=20
right child<BR>{<BR> assert(root !=3D NULL &&=20
root->rightChildPtr =3D=3D =
NULL);<BR> root->rightChildPtr =3D=20
rightTree.root;<BR> rightTree.root =3D NULL;<BR>} // =
end=20
if<BR></CODE>
<HR>
page 526 (Apr. 23, 2004)<BR><BR>In the definition of the function=20
<CODE>copyTree</CODE> at the bottom of the page,<BR>delete the =
<CODE>if</CODE>=20
statement that compares <CODE>newTreePtr</CODE> with =
<CODE>NULL</CODE>.<BR>
<HR>
page 556<BR><BR>Line 3 (Dec. 22, 2004)<BR>Either omit the default =
constructor=20
for <CODE>KeyedItem</CODE> or move it to the private section and delete =
the=20
semicolon. <BR><BR>Line 12 (June 1, 2004)<BR>Replace the comment just =
before the=20
end of the class <CODE>KeyedItem</CODE> with<BR><BR><CODE>//... and =
possibly=20
other data</CODE><BR>
<HR>
page 557 (Dec. 9, 2004)<BR><BR>Skip a line before the signature of=20
<CODE>searchTreeInsert</CODE> and<BR>remove the blank line after it.<BR>
<HR>
page 558 (Jan. 6, 2005)<BR><BR>In the protected section, delete=20
<CODE><B>throw</B>(TreeException)</CODE> from =
<CODE>insertItem</CODE>.<BR>
<HR>
page 560, last line (Apr. 23, 2004)<BR><BR>At the bottom of the page, =
delete the=20
<CODE>throw</CODE> clause from the function <CODE>insertItem</CODE>.<BR>
<HR>
page 561 (Apr. 23, 2004; clarified Jan. 6, 2005)<BR><BR>In the =
definition of the=20
function <CODE>insertItem</CODE> at the top of the page,<BR>delete these =
3=20
lines:<BR><CODE>// was allocation successful?<BR><B>if</B> (treePtr =
=3D=3D=20
NULL)<BR> <B>throw</B> TreeException("TreeException: =
insert=20
failed"); </CODE><BR><BR><FONT color=3Dblue>
<HR>
Chapter 11=20
<HR>
</FONT><BR>page 594 (Dec. 22, 2004)<BR><BR>In <CODE>KeyedItem</CODE>, =
either=20
omit the default constructor or move it to the private section and =
delete the=20
semicolon. <BR>
<HR>
page 605, Line 8 (Dec. 14, 2004)<BR><BR>After the default constructor, =
add the=20
destructor<BR><BR><CODE><B>virtual</B> ~Table();</CODE><BR><BR>and =
change the=20
comments to<BR><BR><CODE>// copy constructor is supplied by the=20
compiler</CODE><BR>
<HR>
page 609, mid-page (Dec. 14, 2004)<BR><BR>After the default constructor, =
add the=20
destructor<BR><BR><CODE><B>virtual</B> ~Table();</CODE><BR><BR>and =
change the=20
comments to<BR><BR><CODE>// copy constructor is supplied by the=20
compiler</CODE><BR>
<HR>
page 609 (Apr. 23, 2004)<BR><BR>Delete the <CODE>throw</CODE> clause =
from the=20
function <CODE>tableInsert</CODE>.<BR>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -