Programming - Errata
Modified November 5, 2010.
This is errata for the 2nd printion of
Programming: Principles and Practice using C++
yiedlding the 3rd printing.
Comments, improvements, bug reports, etc. are welcome.
This is not a list that a reader should go through to carefully correct a copy of the book;
most errata is far too minor to bother or confuse most people.
I recommend using this list only if you suspect a mistake in the book -- look at the errata before doubting your understanding.
I list both corrections and clarifications.
There is essentially no problem that I consider too small to list,
so you might find many pieces of errata too minor to bother with (I know because I have received email to that effect),
but I'd rather not make decisions about what an unknown reader will find bothersome.
Please note that the number of errata does not equal the number of errors.
Most errata are clarifications/improvements, not correction of errors.
The major source of errata is now translators and reviewers of translations:
People who go through the text paragraph-by-paragraph,
sentence-by-sentence, and word-by-word trying to render it
accurately and colloquially in another language find problems that a native English reader rarely spot.
My hope is that the resulting clarifications will be especially valuable for readers of the English text who are (like me)
not native English speakers.
Big issues, such as "why don't you use XXX for your GUI?", "please add two more chapters on the STL",
and "please use C++0x features to simplify the code" are not errata but considerations for future work and
will not appear here.
Different people have different preferences for sorting errata: in chronological order, in page order, each printing separate, all printings merged, etc.
However, I can't manage multiple organizations, so what you get is what seems to be most useful for most people.
At the request of repeat visitors to the page, I have started to add dates of posting of individual errata. If an errata is changed, so is its date.
As an abbreviation I use, s/before/after/ to mean replace "before" with "after".
This is the errata to the 2nd printing. The errata for the 1st printing is
here.
The printing number can be found on the bottom of the copyright page.
Table of contents
Chapter 0
- (+8/16/2010) pg 10: s/Software engineering principles first/"Software engineering principles first"/
Chapter 1
- (+12/8/09) pg 32: s/though web interfaces/through web interfaces/
Chapter 2
Chapter 3
- (+4/11/2010) pg 64: s/22 followed by some random number/22 followed by (age followed by some random number/
- (+4/11/2010) pg 65: s/5.5/five-and-a-half/
- (+4/11/2010) pg 67: s/another name for newline ("end of line")/another name for newline ("end of line") in output/
- (+12/25/09) pg 73: replace '/= and %= are referred to as "scaling"' by '*= and /= are referred to as "scaling"'
- (+4/11/2010) pg 74: s/"repeated: "<</"repeated: " <</
- (+12/25/09) pg 75: s/String s =/STRING s =/
- (+4/11/2010) pg 77: s/don't use/don't use the initial capital letter style/
- (+4/11/2010) pg 77: s/McDonald/MacDonald/
- (+4/25/2010) pg 80: s/error("d1 is negative");/cout << "d1 is negative";/
- (+4/19/2010) pg 81: s/double d =0;/double d = 0;/
- (+4/19/2010) pg 82: s/(always rounds down)/(always rounds down; towards zero)/
- (+4/25/2010) pg 83: s/error("you're kidding!")./simple_error("you're kidding!") using simple_error() from std_lib_facilities.h./
- (+4/19/2010) pg 86: s/You may ...; it can be done.//
Chapter 4
Chapter 5
- (+10/30/2010) pg 138: s/the argument type)/the argument types)/
- (+5/7/2010) pg 138: s/exactly on its type./exactly on its type. For more details see §8.2-3./
- (+5/7/2010) pg 140: s/most common answer./most common approach./
- (+10/30/2010) pg 140: s/This suffices/This approach sufficies/
- (+5/7/2010) pg 149: s/a few exceptions/a few types of exceptions/
- (+5/7/2010) pg 152: s/control statements/if-statements/
- (+8/16/2010) pg 159: s/after the 0/after the 0/
- (+5/7/2010) pg 162: s/no comments documented/no comments/
- (+7/7/2010) pg 168: s/, starting with the first//
Chapter 6
- (+5/17/2010) pg 179: s/among digits and plusses/among digits, plusses, minuses, and parentheses/
- (+5/9/2010) pg 197: s/to avoid/to apply/
- (+5/17/2010) pg 208: s/in the definition of Token above./in the definition of Token in §6.3.3./
- (+6/13/2010) pg 209: s/ get() is defined elsewhere/ get() is defined in §6.8.2/
- (+5/17/2010) pg 213: s"// deal with *, / and %"// deal with * and /" (using " as the substitution separator)
- (+2/23/2010) pg 216: Add a hint to exercise 3:
Hint: The calculator functions deal with doubles, but factorial is defined only for ints,
so just for x! assign the x to an int and calculate the factorial of that int.
Chapter 7
- (+5/22/2010) pg 221: s/If we added/If we used/
- (+5/22/2010) pg 225: s/be the next character to be read/be a character to be read/
- (+5/22/2010) pg 226: s/isn't a primary/isn't a Primary/
- (+12/26/09) pg 229: s/double d = term();/double d = primary();/
- (+5/23/2010) pg 231: s/defining a number/defining an object/
- (+5/22/2010) pg 231: s/number ='0'/For example, an assignment number ='0'/
- (+5/22/2010) pg 234: delete the comment "//quit"
- (+5/23/2010) pg 236: s/repeat an action/explain something/
- (+5/22/2010) pg 238: delete the comment "//quit"
- (+7/9/2010) pg 251: Replace review #18 by: "18. How do you chose names for variables and functions? List
possible reasons."
- (+5/22/2010) pg 251: s/calculator's names/calculator's variable names/
- (+12/26/09) pg 252: exercise 4: s/declare_name()/define_name()/
- (+5/23/2010) pg 252: exercise 4: s/global variable/variable/
- (+12/26/09) pg 252: exercise 9: s/declare()/define()/
Chapter 8
Chapter 9
- (+6/13/2010) pg 307: Replace 12/24/2007/ with (12,24,2007)
- (+3/25/2010) pg 308: s/Ouch! invalid date/Ouch! invalid date (birthday.d==32 makes today invalid)/
- (+3/25/2010) pg 308: s/Ouch! invalid date/Ouch! invalid date (today.m==14 makes today invalid)/
- (+11/16/09) pg 309: s/Georgian/Gregorian/ twice
- (+6/13/2010) pg 310: s/the order of class members/the order of class function and data members/
- (+6/13/2010) pg 310: s/The :y(yy), m(mm), d(dd) notation is how we initialize members. /The :y(yy), m(mm), d(dd) notation is how we initialize members. It is called a (member) initializer list. /
- (+6/13/2010) pg 312: s/can refer to another member/ can refer to a function or data member/
- (+6/13/2010) pg 312: s/ The function will be ... ./The function will be inline; that is, the compiler will try to generate code for the function at each point of call rather than using function call instructions to use common code./
- (+6/13/2010) pg 312: s/, say five lines of code,/, say five or more lines of code,/
- (+6/13/2010) pg 320: s/(x<min || max<x)/ (x<min || max<=x)/
- (+6/13/2010) pg 321: s/if you copy a Month/if you copy a Date/
- (+6/13/2010) pg 323: change the toupper line:
s[i] = toupper(s[i]); // oops: read and write a random memory location
- (+6/13/2010) pg 324: s/Date& default_date()/const Date& default_date()/
- (+3/7/2010)pg 330: add after the first comment line:
#include "Chrono.h"
- (+10/30/2010) pg 330: s/Date& default_date()/const Date& default_date()/
- (+6/13/2010) pg 331: add a test of m after the test of d:
If (m<Date::jan || Date::dec<m) return false;
- (+02/11/2010) pg 332: Add before the last return statement in operator>>():
dd = Date(y,Date::Month(m),d); // update dd
- (+2/5/2010) pg 334: s/the title author, and ISBN/the title, author, and ISBN/ (in excercise #6)
- (+7/5/2010) pg 335: s/long/long int/ four times.
Chapter 10
- (+5/7/2010) pg 340: s/and then access/and programs then access/
- (+7/9/2010) pg 345: s/check that the file/checks if the file/ twice
- (+5/8/2010) pg 345: s/file named name/file named oname/
- (+8/16/2010) pg 345: s/ost <</ ost <</ (indent correctly)
- (+8/16/2010) pg 346: s/ifs is already open/fs is already open/ (in comment)
- (+7/9/2010) pg 347: s/(hour of day,/(hour,/
- (+5/8/2010) pg 351: s/simplify all input loops by/simplify all input loops on ist by/
- (+5/16/2010) pg 355: s/isdigit(ch)/isdigit(ch) || ch=='-'/
Chapter 11
- (+6/16/2010) pg 380: s/similar to that of decimal values/similar to that of integer values/
- (+5/16/2010) pg 382: s/round down/round down (towards zero)/
- (+5/16/2010) pg 382: s/round up/round up (away from zero)/
- (+5/16/2010) pg 390: s/stringstream/istringstream/ three times in the middle paragraph
- (+7/5/2010) pg 390: s/ a string stream really is a kind of istream/an istringstream really is a kind of istream/
- (+6/13/2010) pg 393: s/c isalpha()|isdigit()|ispunct()/isalpha(c) or isdigit(c) or ispunct(c)/
- (+7/5/2010) pg 394): Modify the first sentence to
Note that the classifications can be combined using the ''or'' operator (||). For example,
isalnum(c) means isalpha(c)||isdigit(c); that is, "Is c either a letter or a digit?''
- (+3/25/2010> pg 400: Add "about" as the first word in the final list of words
- (+3/25/2010> pg 401: Add "kind" after "don't" and before "languages" in the list of words
- (+8/17/2010) pg 403: s/setprecision/setprecision()/ twice
- (+12/8/09) pg 404: s/0x4 hexadecimal/0x43 hexadecimal/
- (+1/17/2010) pg 404: Replace the table in exercise 3 with:
0x43 hexadecimal converts to 67 decimal
0123 octal converts to 83 decimal
65 decimal converts to 65 decimal
That is, default-align numbers in fields (left alignment - as suggested by the original table - is hard)
- (+4/25/2010> pg 404: s/" - don't use the as-if rule."/" don t use the as if rule "/
Chapter 12
- (+3/26/2010) pg 425: add to the end of the example at the bottom of the page win.attach(poly_rect);.
- (+5/16/2010) pg 431: s/stringstream/ostringstream/
- (+7/9/2010) pg 433: s/, Window.h, and GUI.h/ and Simple_window.h/
- (+3/26/2010) pg 434: pg 434: s/HTTP/HTML/
- (+12/8/09) pg 434: Change exercise 4 to: Draw a 3-by-3 tic-tac-toe board of alternating white and red squares.
- (+3/26/2010) pg 435: in 13: s/the superellipse shapes/the lines/
Chapter 13
- (+5/16/2010) pg 442: s/to add to/to add a Point to/
- (+2/05/2010) pg 444: s/we get/we get:/
- (+5/16/2010) pg 447: s/Transparency::/Color::/ twice
- (+8/16/2010) pg 448: s/-..-../-..-../
- (+5/17/2010) pg 454: s/existing lines/existing lines (code not shown)/
- (+5/17/2010) pg 461: s/write a simple color chart/draw a simple color chart/
- (+5/16/2010) pg 461: s/set_fill_color(i*16+j);/set_fill_color(Color(i*16+j));/
- (+11/5/2010) pg 464: Change the definitions of set_radius():
void set_radius(int rr)
{
set_point(0,Point(center().x-rr,center().y-rr)); // maintain the center
r = rr;
}
- (+5/17/2010) pg 466: s/write parts of a circle/draw parts of a circle/
- (+11/5/2010) pg 466: Change the definitions of set_major() and set_minor():
void set_major(int ww)
{
set_point(0,Point(center().x-ww,center().y-h)); // maintain the center
w = ww;
}
void set_minor(int hh)
{
set_point(0,Point(center().x-w,center().y-hh)); // maintain the center
h = hh;
}
- (+5/16/2010) pg 467: A better definition of focus1():
Point focus1() const
{
if (h<=w) // foci are on the x-axis:
return Point(center().x+int(sqrt(double(w*w-h*h))),center().y);
else // foci are on the y-axis:
return Point(center().x,center().y+int(sqrt(double(h*h-w*w))));
}
- (+5/16/2010) pg 469: improve Marked_polyline's constructor:
Marked_polyline(const string& m) :mark(m) { if (m=="") mark = "*"; }
- (+5/17/2010) pg 474: simplify the character literal '\"' to '"'
- (+5/17/2010) pg 475: simplify the character literal '\"' to '"'
- (+5/16/2010) pg 475: s/, but effective,//
- (+6/16/2010) pg 475 s/map (see chapter 18)/map (see §21.6)/
- (+4/25/2010) pg 476: s/RBG/RGB/
- (+5/16/2010) pg 477: s/(e.g. see www....)/(e.g. search the web for "RGB color chart")/
- (+5/16/2010) pg 477: s/Hexagon/Regular_hexagon/ twice
- (+5/16/2010) pg 477: s/(a hexagon is a regular six-sided polygon)/(a regular hexagon is a six-sided polygon with all sides of equal length)/
Chapter 14
- (+5/16/2010) pg 489: s/making any member of a class public/making any data member of a class public/
- (+5/16/2010) pg 490: s/set_points()/set_point()/
- (+5/16/2010) pg 490: s/is there,/is provided/
- (+5/16/2010) pg 490: s/size of the program/size of the generated code/
- (+9/13/2010) pg 491: s/line_color/lcolor/
- (+7/5/2010) pg 491: Clarification of the second paragraph of 14.2.3:
Shape’s most basic job is to draw shapes. We could remove all
other functionality from Shape or leave it with no data of its own
without doing major conceptual harm (see §14.4), but drawing is Shape’s
essential business. It does so using FLTK and the operating system’s
basic machinery, but from a user’s point of view, it provides just two
functions:"
- (+9/13/2010) pg 492: s/tries to restore the color and shape/tries to restore color and style/
- (+9/15/2010) pg 495 (in the figure): s/line_color/lcolor) twice and add "fcolor"
- (+5/16/2010) pg 496: s/for a Circle/for a Shape that is a Circle/
- (+9/15/2010) pg 497 (in the figure): s/line_color/lcolor) twice and add "fcolor"
- (+9/15/2010) pg 498 (in the figure): s/line_color/lcolor) twice and add "fcolor"
- (+5/16/2010) pg 502: (the list on the middle of the page): s/If a base is public, its name can be used by all functions./If a base is public, its public member names can be used by all functions./
- (+5/16/2010) pg 503: s/overridden in a derived class/overridden in some derived class/
- (+5/16/2010) pg 508: s/double*/double* (see Chapter 17)/
- (+4/25/2010) pg 508: s/runtime_exception/runtime_error/
Chapter 15
Chapter 16
Chapter 17
- (+6/13/2010> pg 575: s/assign a char (pc) to an int (pi)/assign a char (*pc) to an int (*pi)/
- (+6/4/2010) pg 575: s/point to ch, a/point to ch3, a/
- (+6/14/2010) pg 576: s/you have to use reinterpret_cast/you can use reinterpret_cast/
- (+6/4/2010) pg 582: s/if we don't like the default initializer/if we want to specify element values/
- (+6/4/2010) pg 583: s/(usually 0)/(often 0)/
- (+6/4/2010) pg 584: s/100 doubles unusable/1000 doubles unusable/
- (+6/4/2010) pg 588: in the body of f3(): s/int/double/ five times
- (+6/6/2010) pg 590: s/elem(new double[s]) { }/elem(new double[s]) { /* ... */ }/
- (+3/5/2010) pg 591: s/get(int n) {/get(int n) const {/
- (+6/4/2010) pg 592: s/delete it./delete the object that new created./
- (+6/4/2010) pg 595: clarification the '0' in "0xFF" is zero, not the letter 'o'.
- (+6/4/2010) pg 595: s/Assignment to a reference changes what the reference refers to/Assignment to a reference changes the value of the object referred to/
- (+6/4/2010) pg 596: s/equivalent example for reference/corresponding example for reference/
- (+6/13/2010) pg 598: Extend the first two code fragments:
void rotate(Shape* s, int n); // rotate *s n degrees
Shape* p = new Circle(Point(100,100),40);
Circle c(Point(200,200),50);
rotate(p,35);
rotate(&c,45);
And similarly for references:
void rotate(Shape& s, int n); // rotate s n degrees
Shape& r = c;
rotate(r,55);
rotate(*p,65);
rotate(c,75);
- (+6/4/2010) pg 601: s/if (n<0)/else if (n<0)/
that makes no different in this example, but it is a less error-prone style
- (+6/4/2010) pg 604: Add a const version of find():
Link* find(const string&s); // find s in list
const Link* find(const string& s) const; // find s in const list (see 18.4.1)
Link* advance(int n) const; // move n positions in List
- (+6/4/2010) pg 610: s/Look up realloc() ... if needed//
Chapter 18
- (+6/6/2010) pg 613: s/elem(new double[s]) { }/elem(new double[s]) { /* ... */ }/
- (+7/5/2010) pg 614: add the value 0.0 twice (for v[0] and v[1]) in the figure for v.
- (+6/6/2010) pg 627: s/Use vector/Use std::vector/
- pg 630: Expert-level comment: the "easy to get wrong" backwards loop actually has a subtle error:
It forms a pointer to the (non-existent) element one before the array and compares that to &ad[0].
That's not standards conforming and a very aggressive optimizer may generate bad code for that.
However, that's unlikely because there is a lot of such code "out there".
A correct loop:
for (double* p = &ad[10]; p>&ad[0]; --p) cout << *(p-1) << '\n';
However, you can't just substitute in that version because then the text would be wrong.
- (+7/5/2010) pg 633: s/something like vector/something like the standard library vector/
- (+6/6/2010) pg 641: s/return is_palindrome(++first,––last);/return is_palindrome(first+1,last-1);/
- (+8/14/2010) pg 643: exercise 9: s/Consider the memory layout in §17.3/Consider the memory layout in §17.4/
Chapter 19
- (+6/2/2010) pg 650: s/space is 0/space==sz; that is, there is no "free space'':/
- (+6/2/2010) pg 654: s/self-reference (e.g., v=v)/self-assignment (e.g., v=v)/
- (+6/2/2010) pg 655: s/for 0<=n<sz elem[n] is element n/if 0<=n<sz, elem[n] is element n/
- (+6/2/2010) pg 657: s/size+free_space/size + free space/ twice
- (+6/14/2010) pg 659: s/for a give argument type,/for given object and argument types,/
- (+7/9/2010) pg 664: Add a comment to the definition of printout:
template<class C> void printout(const C& c) // function template
- (+6/7/2010) pg 665: s/add 200/add 100/
- (+6/7/2010) pg 665: s/add 300/add 100/
- (+6/7/2010) pg 666: s/make 200/add 100/
- (+6/2/2010) pg 666: s/four fundamental operators/four fundamental operations/
- (+6/2/2010) pg 667: s/how a vector can deal/how a vector can deal/
- (+6/2/2010) pg 669: replace
cin>>i;
while (i!=-1) try {
while(cin>>i && i!=-1)
try {
- (+6/2/2010) pg 671: s/unsigned int/size_type/ twice
- (+6/2/2010) pg 677: s/some_function()/make_vec()/
- (+6/2/2010) pg 677: s/(vector::at())/(e.g., vector::at())/
- (+10/22/2010) pg 680: replace
for (int i=0; i<this->sz; ++i)
this->alloc.construct(&b.elem[i],this->elem[i]); // copy
with
uninitialized_copy(b.elem,&b.elem[this->sz],this->elem); // copy
- (+6/2/2010) pg 680: Replace the "When we exit reserve() ..." with
"We use the standard-library function uninitialized_copy to construct
copies of the elements from b because
it correctly handles throws from an element copy constructor and because calling
a function is simpler than writing a loop.
When we exit reserve(), the old allocation is automatically
freed by vector_base's destructor if the copy operation succeeded.
If instead that exit is caused by the copy operation throwing an exception,
the new allocation is freed."
- (+6/2/2010) pg 680: s/such as vector_base<T,A>::reserve()./such as vector<T,A>::reserve()./
- (+1/16/2010) pg 681: Revised chapter 19 drill:
1-9 unchanged
10. Replace set() with an S<T>::operator=(const T&). Hint: Much simpler than §19.2.5.
11. Provide const and non-const versions of get();
12-13 unchanged
14: Bonus: Define input and output operators (>> and <<) for vector<T>'s.
For both input and output use a { val, val, val } format.
That will allow read_val() to also handle the S< vector<int> > variable.
- (+7/9/2010) pg 683: Add to exercise 8: Hint: look up "placement new" and "explicit call of destructor" in a complete C++ reference.
- (+7/5/2010) pg 683: exercise 11: s/Give the counted_ptr an initial value for the T/Let counted_ptr's constructor take an argument to be used as the initial value of the T elements/
Chapter 20
- (+7/9/2010) pg 696: s/my code/my algorithms/
- (+7/9/2010) pg 701: s/Basically, the List iterator/Basically, the list iterator/
- (+7/9/2010) pg 703: s/We use this kind of test systematically with STL algorithms./We use testing the return value against end() - indicating ``not
found'' - systematically with STL algorithms./
- (+6/3/2010) pg 705: In the diagram add a . (dot) after "This is the start of a very long document"
- (+6/3/2010) pg 706: In the diagram add a . (dot) after "This is the start of a very long document" and "This is a new line".
- (+6/3/2010) pg 707: delete the comment "// line[i] is the ith line"
- (+6/2/2010) pg 709: s/one beyond the last line/one beyond the last character of the last line/
- (+6/2/2010) pg 709: To match std::advance(), replace the erase_line() definition with
void erase_line(Document& d, int n)
{
if (n<0 || d.line.size()-1<=n) return;
list<Line>::iterator p = d.line.begin();
advance(p,n);
d.line.erase(p);
}
- (+6/2/2010) pg 710: To match std::advance(), replace the advance() definition with
template<class Iter> void advance(Iter& p, int n)
{
while (0<n) {++p; --n; }
}
- (+6/2/2010) pg 710: Replace the second sentence of the first paragraph with:
"In fact, for a vector called v, p=v.begin; advance(p,n); *p=x is roughly equivalent to v[n]=x."
- (+10/19/2010) pg 711: s/++first;/first = ++p;/
- (+6/3/2010) pg 712: vector: s/involve moving characters/involve moving elements/
- (+6/3/2010) pg 712: string: s/are not guaranteed to be contiguous/are guaranteed to be contiguous/
- (+8/17/2010) pg 716: s/Elem*/T*/ (in the comment)
- (+10/4/2010) pg 717: s/the index of the element to be erased/the index at which the element is to be inserted/
- (+11/5/2010) pg 718 : s/typedef T* const_iterator/typedef const T* const_iterator/
- (+11/2/2010) pg 722: s/built-in array/built-in array/
- (+11/4/2010) pg 723: s/randomaccess/random-access/
- (+6/3/2010) pg 726 s/19. Define a range-checked vector for list/19. Define a range-checked iterator for list/
Chapter 21
Chapter 22
- (+6/3/2010) pg 778: s/If we ..., we'd also/We could also/
- (+6/3/2010) pg 778: s/vector<pair<string,Value_type>>/vector< pair<string,Value_type> >/ twice
- (+6/3/2010) pg 806: s/better checking of templates,/improved language facilities, such as/
Chapter 23
- (+6/3/2010) pg 815: s/C-style string/C-style string/
- (+6/3/2010) pg 815: for insert: s/a character, a string, or a C-style string/a string or a C-style string/
- (+6/3/2010) pg 815: for append: s/s.append(pos,x) Insert x after s[pos];/s.append(x) Insert x after the last character of s;/
- (+6/3/2010) pg 815: for append: s/a character, a string, or a C-style string/a string or a C-style string/
- (+6/3/2010) pg 815: s/ operations move characters/operations may move characters/
- (+7/5/2010) pg 815: replace the erase line with
s.erase(pos) Remove trailing characters from s starting with s[pos]. s's size becomes pos
s.erase(pos,n) Remove n characters from s starting at s[pos]. s's size becomes max(pos,size-n)
- (+7/5/2010) pg 815: for find: s/npos/string::npos/
- (+6/4/2010) pg 816: s/a stringstream/an ostringstream/
- (+7/5/2010) pg 818/s/read arg into stream/write arg into stream/
- (+6/4/2010) pg 819: Replace the first sentence started on the page with:
"So if we try to read an int from a string, both
lexical_cast<int>("123") and lexical_cast<int>("123 ")will succeed,
but lexical_cast<int>("123.5") will not because of that last .5."
- (+2/05/2010) pg 825: s/We use the empty string to indicate that an address wasn't found.//
- (+6/4/2010) pg 825: s/a map/a map/ three times
- (+11/5/2010) pg 824: s/sender.equal_range("John Doe");/sender.equal_range("John Doe <jdoe@machine.example>");/
- (+4/28/2010) pg 825: s/sender.equal_range("John Doe");/sender.equal_range("John Doe <jdoe@machine.example>");/
- (+4/28/2010) pg 827): Change find_subject() to match declaration:
string find_subject(const Message* m)
{
for(Line_iter p = m->begin(); p!=m->end(); ++p)
if (int n = is_prefix(*p,"Subject: ")) return string(*p,n);
return "";
}
- (+7/5/2010) pg 828: s/every ZIP code number/every postal code/ twice
- (+7/5/2010) pg 829: s/every ZIP code number/every postal code/
- (+7/5/2010) pg 830: s/simple ZIP code/simple postal code/
- (+7/5/2010) pg 835: s/on the line with ggg/on the line that starts with ggg/
- (+6/4/2010) pg 836: s/ECMAscript/ECMAScript/
- (+6/4/2010) pg 837: s/any three-letter string/any three-character string/
- (+8/16/2010) pg 838: s/{ n }/{n}/
- (+8/16/2010) pg 838: s/{ n, }/{n,}/
- (+7/5/2010) pg 841: last sentence: s/string/string literal/
- (+7/5/2010) pg 842: first sentence: s/string/string literal/
- (+6/4/2010) pg 850: drill 3: s/from drill 1/from drill 2/
- (+7/5/2010) pg 852: exercise 12: yyyy-mm-dd (-s rather than /s)
Chapter 24
- (+6/14/2010) pg 862: s/on the course site/on the book support site/
- (+6/3/2010) pg 870: s/(i,j,k)/(i,j)/
- (+6/14/2010) pg 872: s/the elements from/the rows from/ twice
- (+7/9/2010) pg 876: s/(we should have used elim_with_partial_pivot)/(elim_with_partial_pivot could do better in many cases)/
- (+11/16/09) pg 877 s/24.5.3/24.5.4/
- (+6/3/2010) pg 885: s/Write a double() function/Write a triple() function/
- (+6/3/2010) pg 885: s/double/triple/ four times
Chapter 25
- (+10/4/2010) pg 913: s/the dot in p[i].draw()/the dot in a[i].draw()/
- (+10/4/2010) pg 922: s/(unsigned) int/(signed) int/
- (+10/4/2010) pg 925: s/chars on our machine are unsigned (c behaves as uc and differs from sc)/chars on our machine are signed (c behaves as sc and differs from uc)/
Chapter 26
- (+7/9/2010) pg 958: s/int test_all()/int test_all(istream& is)/
- (+7/9/2010) pg 958: s/(cin>>t)/(is>>t)/
- (+7/9/2010) pg 959: s/test_all()/test_all(ifstream("my_tests.txt"))/
- (+7/5/2010) pg 960: s/the average distance between elements is spread /the average distance between elements is uniformly distributed in [0 :spread)/
- (+7/5/2010) pg 962: s/look not just at the formal parameter/ look not just at the formal parameters/ (missing s)
- (+7/7/2010) pg 965: s/(vector<int>& v)/(const vector<int>& v)/
- (+7/7/2010) pg 976: s/if (ln.color() != i*100)/if (ln.color() != Color(i*100))/
- (+7/7/2010) pg 976: s/if (ln.style() != i*5)/if (ln.style() != Line_style(i*5))/
- (+7/7/2010) pg 977: s/if (2<last–first)/if (2 <= last-first)/
- (+7/7/2010) pg 984: Drill #2 : replace commas with spaces in the test input example.
- (+7/7/2010) pg 986 s/(O(n^2)/O(n*n)/
Chapter 27
- (+1/26/2010) pg 1027: s/malloc(sizeof(struct List*));/malloc(sizeof(struct List));/
Appendix A
- (3/9/09) pg 1079. Before "A.12.4.1 Virtual functions" insert a new paragraph:
Members of a class can be initialized using the member initializer syntax :member(initial_value) (see §A.12.3).
Only members of the class itself, and not members of its base classes can be initialized this way.
A base class can be initialized using the same syntax. For example:
struct Base {
int mb;
Base(int i) : mb(i) { }
};
struct Derived : Base {
int md;
Derived(int y) : md(y) { } // error: forgot to initialize Base
Derived(int x, int y) : md(y), mb(x) { } // error can't initialize base member from derived constructor
Derived(int x, int y) :Base(y), md(x) { } // ok
};
An initializer used to initialize a base is class a base initializer or base-class initializer.
Appendix B
Appendix C
Appendix E
Glossary
Bibliography
Index
Thanks
Ross Driedger,
Matthew Earnshaw,
Leonid V. Fedorenchik, Eugene Feoktistov,
Salvador García,
Chris Hall,
Loïc Joly,
Byunghoon Kim,
Seppo Laakko, John Lakos, Smith Long,
Hannah McQuilken, Bogdan Maties, Michel Michaud, Mark Millard,
Marcelo Pinto,
Saud Shaheen,
Michael F. Wasserman, Art Werschulz,
Matt Zieleman
Most of the improvements provided here are the result of systematic work by Loïc Joly and Michel Michaud
as part of a very thorough review of both the English text and a draft French translation.