?? walls and mirrors c++ (4th ed_) errata.mht
字號:
From: <由 Microsoft Internet Explorer 5 保存>
Subject: Walls and Mirrors: C++ (4th ed.) Errata
Date: Wed, 9 May 2007 22:22:26 +0800
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----=_NextPart_000_0000_01C79288.860B8D20"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
This is a multi-part message in MIME format.
------=_NextPart_000_0000_01C79288.860B8D20
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.cs.uri.edu/~carrano/WMcpp4e/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Walls and Mirrors: C++ (4th ed.) Errata</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.3059" name=3DGENERATOR></HEAD>
<BODY text=3Dblack bgColor=3Dwhite>
<CENTER><IMG height=3D178 alt=3D" "=20
src=3D"http://www.cs.uri.edu/~carrano/WMcpp4e/rcoverWMcpp4e.jpg" =
width=3D144=20
align=3Dcenter border=3D1></CENTER>
<CENTER>
<H2>Data Abstraction and Problem Solving with C++<BR>Walls and Mirrors=20
<BR>(4<SUP>th</SUP> edition) </H2>by Frank M. Carrano<BR><BR>
<H2>Errata List</H2></CENTER><BR><FONT color=3Dblue>Last updated on =
December 13,=20
2005. </FONT><BR>The date after each error is the date it was posted on =
this=20
list. Subsequent printings of the book will correct these =
errors.<BR><BR>If you=20
find an error and it is not on this list, please <A=20
href=3D"mailto:carrano@acm.org">e-mail</A> a description of the error =
and the page=20
number.<BR><BR><FONT color=3Dblue>
<HR>
Chapter 1=20
<HR>
</FONT><BR>Page 11 (Apr. 23, 2004)<BR><BR>In the lower half of the page, =
the=20
comments in the code should have superscripts, as =
follows:<BR><BR><CODE>//=20
Computes an approximation to e<SUP>x</SUP> for a real x<BR><BR>// =
Invariant: t=20
=3D=3D x<SUP>k-1</SUP>/(k-1)! and<BR>// s =3D=3D=20
1+x+x<SUP>2</SUP>/2!+...+x<SUP>k-1</SUP>/(k-1)!<BR></CODE><BR><FONT =
color=3Dblue>
<HR>
Chapter 2=20
<HR>
</FONT><BR>Page 111, Exercise 23 (Feb. 7, 2005)<BR><BR>In the definition =
of the=20
function <CODE>gcd</CODE>, the first return value should be =
<CODE>b</CODE>=20
instead of <CODE>a</CODE>. Thus, replace<BR><BR><CODE><B>if</B> ( a % b =
=3D=3D 0 )=20
//base case<BR> <B>return</B>=20
a;<BR><BR></CODE>with<BR><BR><CODE><B>if</B> ( a % b =3D=3D 0 ) //base=20
case<BR> <B>return</B> b;<BR></CODE><BR><FONT =
color=3Dblue>
<HR>
Chapter 3=20
<HR>
</FONT><BR>Page 131 (Dec. 13, 2005)<BR><BR>In the last axiom on the =
page, change=20
<CODE>retrieve(x)</CODE> to <CODE>retrieve(i)</CODE><BR><BR><FONT =
color=3Dblue>
<HR>
Chapter 4=20
<HR>
</FONT><BR>Page 171 (Apr. 23, 2004)<BR><BR>Item 5 should read, as=20
follows:<BR><BR>5. If, for some reason, <CODE><I>new</I></CODE> cannot =
allocate=20
memory, it throws the=20
exception<BR><BR> <CODE>std::bad_alloc</CODE><BR>
<HR>
Page 172 (Apr. 23, 2004)<BR><BR>Delete Item 6.<BR>Change 7 to =
6.<BR>Erase the=20
number 8.<BR>
<HR>
Page 174, first paragraph (May 5, 2004)<BR><BR>Replace the first =
sentence=20
with<BR><BR>You also can use a <B>pointer offset notation</B> to =
reference any=20
array element.<BR><BR>Replace the sentence in parentheses =
with<BR><BR>This=20
notation uses <B>pointer arithmetic.</B> <BR>
<HR>
Page 179, next-to-last paragraph, Line 4 (Apr. 23, 2004)<BR><BR>Change=20
<CODE><I>*Node</I></CODE> to <CODE><I>Node*</I></CODE><BR>
<HR>
Page 189, (Apr. 26, 2004)<BR><BR>Delete the <CODE>#include</CODE> =
statement for=20
<CODE>ListException</CODE>.<BR>Delete <CODE>ListException</CODE> from =
the=20
<CODE>throw</CODE> clause of the function <CODE>insert</CODE>.<BR>
<HR>
Page 191, next-to-last line of code (Apr. 23, 2004)<BR><BR>Delete the=20
<CODE>assert</CODE> statement.<BR>
<HR>
Page 192, Line 9 (Apr. 23, 2004)<BR><BR>Delete the <CODE>assert</CODE>=20
statement.<BR>
<HR>
Page 194 (Apr. 26, 2004)<BR><BR>Add a <CODE>throw</CODE> clause to each =
of the=20
definitions of the functions <CODE>retrieve</CODE> and =
<CODE>insert</CODE>, so=20
that they begin<BR><BR><CODE>void List::retrieve(int index, =
ListItemType&=20
dataItem) const =
throw(ListIndexOutOfRangeException)</CODE><BR><BR><CODE>void=20
List::insert(int index, ListItemType newItem)=20
throw(ListIndexOutOfRangeException)</CODE><BR><BR>When the functions=20
<CODE>retrieve</CODE> and <CODE>insert</CODE> throw an exception, the =
message=20
should begin ListIndexOutOfRangeException instead of=20
ListOutOfRangeException.<BR>
<HR>
Pages 194 - 195 (Apr. 26, 2004)<BR><BR>In the definition of the function =
<CODE>insert</CODE>, do not compare <CODE>newPtr</CODE> <BR>with=20
<CODE>NULL</CODE> after a new <CODE>ListNode</CODE> is allocated. =
Instead,=20
replace <BR>the <CODE>else</CODE> clause of the first <CODE>if</CODE> =
statement=20
with<BR><BR><CODE>else<BR>{ // create new node and place newItem in=20
it<BR> ListNode *newPtr =3D new ListNode;<BR> size =
=3D=20
newLength;<BR> newPtr->item =3D =
newItem;<BR><BR> //=20
attach new node to list<BR> if (index =3D=3D =
1)<BR> { //=20
insert new node at beginning of list<BR> =
newPtr->next =3D=20
head;<BR> head =3D=20
newPtr;<BR> }<BR> else<BR> { ListNode =
*prev =3D=20
find(index-1);<BR> // insert new node after=20
node<BR> // to which prev points<BR> =
newPtr->next =3D prev->next;<BR> prev->next =
=3D=20
newPtr;<BR> } // end if<BR>} // end if<BR></CODE>
<HR>
Page 195 (Apr. 26, 2004)<BR><BR>Add a <CODE>throw</CODE> clause to the=20
definition of the function <CODE>remove</CODE>, so that it=20
begins<BR><BR><CODE>void List::remove(int index)=20
throw(ListIndexOutOfRangeException)</CODE><BR><BR>When =
<CODE>remove</CODE>=20
throws an exception, the message should begin =
ListIndexOutOfRangeException=20
instead of ListOutOfRangeException.<BR>
<HR>
Page 206 (Apr. 23, 2004)<BR><BR>Replace<BR><BR><CODE><B>if</B> (newPtr =
=3D=3D=20
NULL)<BR> <B>throw</B> ListException("ListException: insert cannot =
allocate memory");<BR><B>else</B><BR>{ newPtr->item =3D =
newItem;<BR> =20
newPtr->next =3D headPtr;<BR> headPtr =3D newPtr;<BR>} // end =
if=20
</CODE><BR><BR>with<BR><BR><CODE>newPtr->item =3D =
newItem;<BR>newPtr->next =3D=20
headPtr;<BR>headPtr =3D newPtr;<BR></CODE><BR><FONT color=3Dblue>
<HR>
Chapter 5=20
<HR>
</FONT><BR>page 259 (May 5, 2004)<BR><BR>Replace the first line of the=20
pseudocode function <CODE><I>endPre</I></CODE> =
with<BR><BR><CODE><I>+endPre(in=20
first: integer): integer</I></CODE><BR><BR><FONT color=3Dblue>
<HR>
Chapter 6=20
<HR>
</FONT><BR>Page 297 (Apr. 23, 2004)<BR><BR>Line 2: Delete the =
<CODE>throw</CODE>=20
clause from the function <CODE>push</CODE>.<BR><BR>At the bottom of the =
page,=20
delete two <CODE>assert</CODE> statements.=20
<HR>
Page 298 (Apr. 23, 2004)<BR><BR>Delete the <CODE>throw</CODE> clause =
from the=20
function <CODE>push</CODE>.<BR><BR>Replace the <CODE>if-else</CODE> =
statement in=20
the function <CODE>push</CODE> with<BR><BR><CODE>// set data portion of =
new=20
node<BR>newPtr->item =3D newItem;<BR><BR>// insert the new=20
node<BR>newPtr->next =3D topPtr;<BR>topPtr =3D newPtr;<BR></CODE>
<HR>
Page 320 (Apr. 26, 2004)<BR><BR>Indent the statements<BR><BR><CODE>if=20
(!aStack.isEmpty())<BR> aStack.getTop(topCity);<BR></CODE><BR>=
so that=20
the <CODE>if</CODE> statement aligns with the preceding close=20
brace.<BR><BR><FONT color=3Dblue>
<HR>
Chapter 7=20
<HR>
</FONT><BR>Page 347 (Apr. 23, 2004)<BR><BR>Delete the <CODE>throw</CODE> =
clause=20
from the function <CODE>enqueue</CODE><BR>and the comments that describe =
the=20
exception.<BR>
<HR>
Page 348 (Apr. 23, 2004)<BR><BR>Delete the <CODE>throw</CODE> clause =
from the=20
function <CODE>enqueue</CODE>.<BR><BR>Replace the <CODE>if-else</CODE> =
statement=20
in the function <CODE>enqueue </CODE>with<BR><BR><CODE>newPtr->item =
=3D=20
newItem;<BR>newPtr->next =3D NULL;<BR></CODE>
<HR>
Page 349 (Apr. 23, 2004)<BR><BR>Delete the line<BR><BR><CODE>} // end=20
if</CODE><BR><BR><FONT color=3Dblue>
<HR>
Chapter 8=20
<HR>
</FONT><BR>Page 400, Figure 8-9b (Jan. 6, 2005)<BR><BR>The first line of =
the=20
function <CODE>displayStatistics</CODE> should be =
<BR><BR><CODE><B>virtual=20
void</B> displayStatistics() <B>const</B> </CODE><BR>
<HR>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -