Programming - Errata
Modified October 20, 2010.
This is errata for the 1st printing of
Programming: Principles and Practice using C++
giving the 2nd printing.
Comments, improvements, bug reports, etc. are welcome.
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 at this stage, 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.
I say this because I have seen the book condemned unread because the number of errata.
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 first printing of the book.
It was applied to produce the 2nd printing.
Table of contents
- (+5/15/09) pg vi: s/delete repeated words/detect repeated words/
Chapter 0
- (+) pg 11: s/Appendix E/Appendix C/
Chapter 1
- (+) pg 22: s/animators,// (need not to be mentioned twice in the same sentence)
- (+2/24/09) pg 34: s/www.research.att/~bs/applications.html/www.research.att.com/~bs/applications.html/
Chapter 2
- (+4/4/09) pg 48: s/You'll find that computers/You'll find that compilers/
- (+) pg 52: s/Appendix D/Appendix C/
- (+) pg 53: s/Appendix D/Appendix C/
- (+) pg 55: s/repeating exercise 4/repeating exercise 5/
Chapter 3
- (+5/20/09) pg 60: s/delete repeated/detect repeated/
- (+5/15/09) pg 61: s/read characters into name/read characters into first_name/
- (+2/24/09) pg 65: s/Hello 22/Hello, 22/
- (+4/2/09) pg 65: s/and the character literal '\n'//
- (+4/15/09) pg 65: s/string literals "Hello, " and " (age "./string literals "Hello, ", " (age ", and ")\n"./
- (+) pg 67: s/3.7/3.9.1/
- (+5/15/09) pg 71: s/delete repeated words/detect repeated words/
- (+7/19/09) pg 73: s/count repeated words/find repeated words/
- (+4/2/09) pg 82: s/[0,127]/[0:127]/
Chapter 4
Chapter 5
- (+4/2/09) pg 135: s/int s1 = area(7)/int s2 = area(7)/
- (+2/24/09) pg 137: s/OK,/OK:/
- (+4/2/09) pg 141: s/frame_area/framed_area/ twice
- (+5/22/09) pg 141: s/2nd area() argument/argument for area()/
- (+2/24/09) pg 142: s/frame_area/framed_area/
- (+4/2/09) pg 143: s/5.9/5.10/
- (+3/9/09) pg 145: s/width <=0/width<=0/
- (+2/24/09) pg 146: s/a vector ints/a vector of ints/ (in the comment)
- (+2/24/09) pg 147: s/a vector ints/a vector of ints/ (in the comment)
- (+) pg 147: s/out_of_range_error/out_of_range/
- (+3/9/09) pg 151: s/it produces a new value corresponding to its operand of the required type./
it produces a new value (of the type specified in the < ... >) that corresponds to its operand value./
- (+3/20/09) pg 155: s/9.65685/10.3923/
- (+) pg 157: s/terminal/computer/
- (+4/5/09) pg 168, exercise 7: remove redundant advice: s/and have it throw ... if there is an error.//
(The reader can decide what to do about errors).
- (+9/23/09) pg 168, exercise 8: change to simplify exercise:
s/Write a program ... 48."/
Write a program that reads and stores a series of integers
and then computes the sum of the first N integers.
First ask for N, then read the values into a vector,
then calculate the sum of the first N values. For example:
Please enter the number of values you want to sum:
3
Please enter some integers (press '|' to stop):
12 23 13 24 15 |
The sum of the first 3 numbers ( 12 23 13 ) is 48
Chapter 6
- (+6/22/09) pg 178: Add an output line and a test to the example:
cout << "Please enter expression (we can handle +, -, *, and /)\n";
cout << "add an x to end expression (e.g., 1+2*3x): ";
int lval = 0;
int rval;
char op;
cin>>lval; // read leftmost operand
if (!cin) error("no first operand");
while (cin>>op) { // read operator and right-hand operand repeatedly
if (op!='x') cin>>rval;
if (!cin) error("no second operand");
- (+) pg 183: s/We can read out input/We can read input/
- (+) pg 183: s/read token from cin/function to read token from cin/
- (+) pg 189: s/(again leaving/(leaving/
- (+) pg 190: s/Expression*Term rule/Expression+Term rule/
- (+) pg 198: s/6.5.3.1/6.5.2.1/
- (+5/24/09) pg 199: /question 4 above/question 5 in sec6.3.5/
- (+) pg 202: s/5+6+7/5+6/ twice
(if you use 5+6+7 the output is far harder to understand with than that from plain 5+6, and the solution harder to spot).
- (+) pg 203: s/5+6+7/5+6/ three times
- (+) pg 203: s/18/11/ twice
- (+4/2/09) pg 207: s/6.5.1/6.3.3/
- (+4/2/09) pg 209, end of page: empty shouldn't be in code font
- (+) pg 210: s/6.5.1/6.3.3/
- (+) pg 211: the opening { of the Token::get() function is indented -- it should not be.
(A compiler can't tell the difference, but we can and code should be aestetically pleasing).
- (+5/25/09) pg 211: s/ case '%'://
- (+) pg 215: Questions 1 and 6 should be merged into one question 1.
- (+) pg 217: s/P(a-b)/P(a,b)/
Chapter 7
- (+4/2/09) pg 226: s/The first thing that expression does is to look for a primary(),and now it finds q. /
The first thing that expression() does is to call term(), which first calls primary(), which finds q./
- (+4/20/09) pg 229: s/= 0/= 2/
- (+3/22/09) pg 230: s/left *= term();/left *= primary();/
- (+3/22/09) pg 230: s/double d = term();/double d = primary();/ twice
- (+) pg 230: in the bottom code fragment: s/f (i2==0)/if (i2==0)/
- (+) pg 232: s/cin.putback()/cin.putback(ch)/
- (+) pg 237: properly align "- Primary" and "+Primary"
- (+9/20/09) pg 238 s/Tokenstream's buffer/the Tokenstream's and cin's buffers/
- (+4/11/09) pg 247: s/struct Token {/class Token { public:/ with the "public:" on its own line, like this
class Token {
public:
(to exactly match pg 182).
- (+4/2/09) pg 247: s/7.8.2/7.8.1/
- (+) pg 252: s/the H key./the H key (both upper and lower case)./
- (+4/2/09) pg 252: s/After analyzing its output/After analyzing its input/
Chapter 8
Chapter 9
- (+2/24/09) pg 307: The dot in /initializer syntax./ is blue (code font); it should be black (text font).
- (+4/2/09) pg 312, last paragraph: s/print out /return the value of/
- (+3/29/09) pg 314: s/and add_date() will have/and add_day() will have/
- (+4/2/09) pg 317: s/Month m = sep;/Month m = Sep;/
- (+2/24/09) pg 323: s/for (int i=0, i<s.size(), ++i)/for (int i=0; i<s.size(); ++i)/
- (+3/11/09) pg 334: s/operator<</operator <</ with only the "<<" in code font
- (+3/11/09) pg 334: s/have functions that access these methods/have functions that access this data/
- (+3/11/09) pg 334: s/Have a helper method/Have a helper function/
- (+3/11/09) pg 335: s/Also create a method/Also write a function/
- (+3/11/09) pg 335: s/a set of useful helper function/a set of useful helper functions/
Chapter 10
- (+6/12/09) pg 346: s/if(fs)/if(!fs)/
- (+3/13/09) pg 351: s/see sec10.6 and // (This *is* section 10.6)
- (+2/24/09) pg 351: s/and Langer, Standard C++ IOStreams and Locales./and Standard C++ IOStreams and Locales by Langer./
Chapter 11
Chapter 12
(+10/5/09) pg 435: in 12: s/the number of points connect to/the number of other points to connect a point to/
Chapter 13
- (+6/23/09) pg 441: s/max_x()/x_max()/
- (+6/23/09) pg 441: s/max_y()/y_max()/
- (+) pg 445: s/fl_draw()/fl_line()/
- (+6/12/09) pg 454: s/Shape::add(p)/Closed_polyline::add(p)/
- (+7/23/09) pg 455: s/Rectangle(Point xy, int hh, int ww)/Rectangle(Point xy, int ww, int hh)/
- (+3/24/09) pg 461: s/8-by-8/16-by-16/
- (+7/20/09) pg 463: s/return Font(fnt);/return fnt;/
- (+3/9/09) pg 470: Add a paragraph just before section "13.16 mark":
"The :Marked_polyline(m) notation is used to initialize the Marked_polyline part of a Marks object.
This notation is a variant of the syntax used to initialize members (9.4.4)."
- (+6/12/09) pg473: s/path's point (50,600)/path's point (50,250)/
Chapter 14
- (+3/20/09) pg 489: s/points start out/points starts out/
- (+3/20/09) pg 489: s/to the members to all members/to all members/
- (+3/31/09) pg 492: s/draw_line()/draw_lines()/ twice
- (+6/12/09) pg 495 s/The Window would know nothing about a copy, so a
/For example, if a Window held only a copy of a Shape, rather than a reference to the Shape, changes
to the original would not affect the copy. So if we changed
the Shape's color, the Window would not notice the change and would display its copy with the unchanged color. A/
- (+6/4/09) pg 498: s/vpt/vptr/ twice in the figure
- (+6/4/09) pg 498: s/:/::/ three time in the figure
- (+6/12/09) pg 504: s/we could override Shape::draw()/we could override Shape::draw_lines()/
Chapter 15
- (+6/19/09) pg 515: s/orig, r_min, r_max/r_min, r_max, orig/
- (+6/19/09) pg 516: s/orig, r_min, r_max/r_min, r_max, orig/
- (+3/22/09) pg 518: s/result is/result is:/
- (+3/31/09) pg 525: The lower image should be that of the iteration with ten terms: ten.
- (+3/31/09) pg 531: last line: s/xy/ys/
- (+5/6/09) pg 532: s/current_line/current_year/
- (+4/3/09) pg 533: s/xy/ys/
- (+4/3/09) pg 537: s/11- .../11+ .../
- (+3/22/09) pg 537: s/about 2.54cm/2.54cm/
(e.g., see definitions).
Chapter 16
- (+4/3/09) pg 540: s/or XML//
- (+6/12/09) pg 544: s/wait_for_button();/void wait_for_button();/
- (+3/24/09) pg 547: s/becomes unobscured/becomes visible/
- (+3/24/09) pg 548: indent ``virtual void move(int dx,int dy);''
- (+4/6/09) pg 552: There should be no color button on the screen shot.
- (+4/6/09) pg 553: There should be no color buttonon the screen shot.
- (+6/12/09) pg 561: The member initializers should be in declaration order, that is:
Lines_window::Lines_window(Point xy, int w, int h, const string& title)
:Window(xy,w,h,title),
next_button(Point(x_max()-150,0), 70, 20, "Next point", cb_next),
quit_button(Point(x_max()-70,0), 70, 20, "Quit", cb_quit),
next_x(Point(x_max()-310,0), 50, 20, "next x:"),
next_y(Point(x_max()-210,0), 50, 20, "next y:"),
xy_out(Point(100,0), 100, 20, "current (x,y):"),
color_menu(Point(x_max()-70,30),70,20,Menu::vertical,"color"),
menu_button(Point(x_max()-80,30), 80, 20, "color menu", cb_menu)
{
- (+3/24/09) pg 562: s/line for line/line by line/
Chapter 17
- (+) pg 574: In the 2nd figure on the page is the number 4099 (in bold); that should be 4096 (of course).
- (+3/12/09) pg 580: s/8.9/8.8/
- (+5/31/09) pg 589: s/the Text object/the Text (13.11) object/
- (+5/31/09) pg 590: s/delete p/delete q/ four times
- (+5/31/09) pg 590: s/delete looks at p'/delete looks at q's/
- (+) pg 599: s/norse_gods = new Link("Odin",norse_gods,0);/norse_gods = new Link("Odin",0,norse_gods);/
- (+) pg 599: s/norse_gods = new Link("Freia",norse_gods,0);/norse_gods = new Link("Freia",0,norse_gods);/
The code as written on page 599 will crash.
Actually, the code posted on www.stroustrup.com/Programming says it will crash, but the text does not.
This became a far better than intended example of why I (as stated) dislike this kind of code.
Oops!
- (+4/16/09) pg 604: delete the second version of the find() function (the const ... const version).
overloading on const is not explained until later.
- (+3/31/09) pg 604: s/We left the value/We left value/ with "value" in code font
Chapter 18
- (+) pg 617: s/copy(a);/for(int i=0; i<a.sz; ++i) p[i]=a.elem[i];/
- (+) pg 618: s/copy(a);/for(int i=0; i<a.sz; ++i) p[i]=a.elem[i];/
- (+4/10/09) pg 621, second line: the "and" before vector<int>() should not be blue.
- (+6/23/09) pg 622: s/<double>// five times
- (+3/21/09) pg 623: The definition of X prints only the old value of an X;
it would be more useful if both the old and the new value was printed. Replace the definition of X by:
struct X { // simple test class
int val;
void out(const string& s, int nv)
{ cerr << this << "->" << s << ": " << val << " (" << nv << ")\n"; }
X(){ out("X()",0); val=0; } // default constructor
X(int v) { out( "X(int)",v); val=v; }
X(const X& x){ out("X(X&)",x.val); val=x.val; } // copy constructor
X& operator=(const X& a) // copy assignment
{ out("X::operator=()",a.val); val=a.val; return *this; }
~X() { out("~X()",0); } // destructor
};
- (+) pg 624: s/delete pp;/delete[] pp;/
- (+4/14/09) pg 627: s/const double &/const double&/
- 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.
- (+5/31/09) pg 639: s/last character read into p/last character read into buffer/
- (+4/15/09) pg 642: s/argument array/argument vector/ (with "vector" in code font)
Chapter 19
- (+) pg 648: s/vector<double> d;/vector<double> vd;/
- (+4/15/09) pg 648: s/be not be/not be/
- (+3/13/09) pg 655: s/vector(int s)/explicit vector(int s)/
- (+3/13/09) pg 657: s/vector(int s)/explicit vector(int s)/
- (+3/13/09) pg 657: s/vector_char(int s)/explicit vector_char(int s)/
- (+3/14/09) pg 663 in "(the size parameter N)", the "N" should be in the blue code font
- (+5/5/09) pg 664: s/array doesn't have those problems/like vector, array doesn't have those problems/
- (+8/27/09) pg 666 s/tries to make 100 No_default()s/tries to make 200 No_default()s/
- (+8/27/09) pg 678 s/with the object we got from new./with the pointer we got from new./
- (+3/13/09) pg 671: s/Vector(size_type n)/explicit Vector(size_type n)/
- (+4/5/09) pg 672: s/ Fine handles/File handles/
- (+3/17/09) pg 678: s/19.3.5./19.3.6./
- (+) pg 680: Replace
template<class T, class A>
void vector<T,A>::reserve(int newalloc)
{
if (newalloc<=space) return; // never decrease allocation
vector_base<T,A> b(alloc,newalloc); // allocate new space
for (int i=0; i<sz; ++i) alloc.construct(&b.elem[i],elem[i]); // copy
for (int i=0; i<sz; ++i) alloc.destroy(&telem[i]); // destroy old
swap< vector_base<T,A> >(*this,b); // swap representations
}
with
template<class T, class A>
void vector<T,A>::reserve(int newalloc)
{
if (newalloc<=this->space) return; // never decrease allocation
vector_base<T,A> b(this->alloc,newalloc); // allocate new space
for (int i=0; i<this->sz; ++i) this->alloc.construct(&b.elem[i],this->elem[i]); // copy
for (int i=0; i<this->sz; ++i) this->alloc.destroy(&this->elem[i]); // destroy old
swap< vector_base<T,A> >(*this,b); // swap representations
}
(I forgot - and forgot to mention - that "this->" is required when accessing a member of a template base class of a
template class.
Not all compilers enforce this rule. When you re-test, re-test on every compiler you use.)
- (+4/19/09) pg 680: add after the last sentence (ending "we wanted."):
Similarly, we have to explicitly use this-> when we refer to a member of the base class vector_base<T,A> from a member of the derived class vector<T,A>, such as base<T,A>::reserve().
- (+3/29/09) pg 681: s/operator[]./operator[]()./ twice.
- (+6/12/09) pg 681: s/Define template<class T> ostream& operator<<(ostream&, vector<T>&)/Define template<class T> istream& operator>>(istream&, vector<T>&)/
- (+4/20/09) pg 682: Replace exercise 1 with this formulation: "Write a template function f() that adds the elements of one vector<T> to the elements of another; for example, f(v1,v2) should do v1[i]+=v2[i] for each element of v1."
Chapter 20
- (+3/11/09) pg 687:
replace
if (h<jack_data[i])
jack_high = &jack_data [i]; //save address of largest element
by
if (h<jack_data[i]) {
jack_high = &jack_data[i]; //save address of largest element
h = jack_data[i]; //update "largest element"
}
- (+3/11/09) pg 687:
replace
if (h<(*jill_data)[i])
jill_high = &(*jill_data)[i]; //save address of largest element
by
if (h<(*jill_data)[i]){
jill_high = &(*jill_data)[i]; //save address of largest element
h = (*jill_data)[i]; //update "largest element"
}
- (+5/9/09) pg 687: s/The function from_jill()/The function get_from_jill()/
- (+3/11/09) pg 688:
replace
if (h<v[i]) jill_high = &v[i];
by
if (h<v[i]) {
jill_high = &v[i];
h = v[i];
}
- (+4/19/09) pg 688: s/high = p;/{ high = p; h = *p; }/
- (+3/9/09) pg 690: s/high = &v[i];/{ high = &v[i]; h = v[i]; }/
- (+8/27/09) pg 699 in the picture it should read val instead of Elem
- (+3/31/09) pg 700: s/is central in/is central to/
- (+) pg 701: s/{ return val; }/{ return curr->val; }/
- (+3/31/09) pg 706: s/String and processing data/Storing and processing data/
- (+7/22/09) pg 707 s/while (is>>ch)/while (is.get(ch))/
- (+7/25/09) pg 707: Add before "return is;":
if (d.line.back().size()) d.line.push_back(Line()); // add final empty line
- (+7/25/09) pg 708: s/an empty Document to have one/a Document to end with a/
- (+7/25/09) pg 708: Improved ++:
Text_iterator& Text_iterator::operator++()
{
++pos; // proceed to next character
if (pos==(*ln).end()) {
++ln; // proceed to next line
pos = (*ln).begin(); // bad if ln==line.end(); so make sure it isn't
}
return *this;
}
- (+) pg 709:
replace
Text_iterator end() // one beyond the last line
{ return Text_iterator(line.end(), (*line.end()).end()); }
with
Text_iterator end() // one beyond the last line
{
list<Line>::iterator last = line.end();
--last; // we know that the document is not empty
return Text_iterator(last, (*last).end());
}
- (+7/25/09) pg 709: s/The call advance(n) moves an iterator n elements forward/A call advance(p,n) moves an iterator p n elements forward/
- (+7/25/09) pg 711: Add a ++first; to find_text():
Text_iterator find_text(Text_iterator first, Text_iterator last, const string& s)
{
if (s.size()==0) return last; // can't find an empty string
char first_char = s[0];
while (true) {
Text_iterator p = find(first,last,first_char);
if (p==last || match(p,last,s)) return p;
++first; // look at the next character
}
}
- (+4/20/09) pg 714: s/3rd element/4th element/ twice
- (+4/20/09) pg 714: s/4th element/5th element/ twice
- (+8/27/09) pg 716 s/we implement vector<T>::erase()/we implement vector<T,A>::erase()/
- (+6/20/09) pg 716: s/destroy(&*pos)/destroy(&*(end()-1)))
- (+) pg 717: replace
if (size()==capacity()) reserve(2*size()); // make sure we have space
with
if (size()==capacity()) reserve(size()==0?8:2*size()); // make sure we have space
- (+) pg 717: Replace
*(begin()+offset) = val; // "insert" val
return pos;
with
*(begin()+index) = val; // "insert" val
return pp;
As I said: always re-test even after the slightest change - in this case I renamed local variables,
but didn't re-test until later.
- (+) pg 717: s/elem+space/elem+sz/ in the text; the code is correct
- (+) pg 721: s/The C++ Programming Library/The C++ Programming Language/
- (+4/26/09) pg 724: s/copy (Iter f1, Iter1 e1, Iter2 f2)/Iter2 copy (Iter1 f1, Iter1 e1, Iter2 f2)/
- (+4/26/09) pg 724: s/just like the standard library copy./and returns f2+(e1-f1) just like the standard library copy./
- (+5/5/09) pg 726: Add as the second to last sentence of the postscript:
"In fact, this underestimates the saved effort because many algorithms take two pairs of iterators and the pairs need not be of the same type (e.g. see exercise 6)."
Chapter 21
Chapter 22
- (+8/27/09) pg 778: s/22.2.8/22.2.6/
- (+8/27/09) pg 782 s/Simula (22.2.6)/Simula (22.2.4)/
- (+6/15/09) pg 784 s/1948/1949/ (to be precise, it ran on May 6, 1949)
- (+4/28/09) pg 776: s/often achieved though/often achieved through/
Chapter 23
- (+8/27/09) pg 814 s/regular expressions (23.3-10)/regular expressions (23.5-10)/
- (+8/27/09) pg 825 s/called senders/called sender/
- (+6/15/09) pg 828: s/isletter/isalpha/
- (+6/15/09) pg 828: s/is a letter/is a letter/ (no code font)
- (+5/6/09) pg 829: s/12 June 2007/5 June 2007/
- (+5/5/09) pg 830: s/Maddoc's/Maddock's/
- (+8/27/09) pg 841 s/an English vowel or a ^/a space, a ^, or an English vowel/
- (+8/21/09) pg 846: s/so we get ^([\w ]+)/so we get ^[\w ]+/
- (+5/5/09) pg 847: s/regex_match/regex_match()/ 3 times in the text
- (+5/5/09) pg 847: s/regex_search/regex_search()/ 3 times in the text
- (+5/5/09) pg 849: s/lexical_cast/lexical_cast()/
- (+5/5/09) pg 849: s/the from_string function/from_string()/
- (+8/21/09) pg 849: s/Maddoc/Maddock/
- (+8/27/09) pg 850, s/23.7.7/23.7/
- (+6/15/09) pg 851: s/.../----/
Chapter 24
- (+8/27/09) pg 856 s/to a floating-point number/to a floating-point variable/
- (+8/27/09) pg 858 s/complex (24.8)/complex (24.9)/
- (+10/1/09) pg 858 s/In <limits>, <limits.h>/In <limits>, <climits>, <limits.h>/
- (+8/27/09) pg 864 s/print the elements of a row by row/print the elements row by row/
- (+) pg 865: s/10/8/ three times
- (+4/8/09) pg 865: s/from the a[i]/from a[i]/ twice
- (+) pg 870: s/7/1/ twice on the swap_rows line
- (+) pg 870: s/9/2/ twice on the swap_rows line
- (+8/27/09) pg 875: s/))) pivot_row = j/)))pivot_row = k/
- (+6/23/09) pg 879: s/rand_int/randint/ four times
- (+5/8/09) pg 883: s/Matrix<int> b(10)/Matrix<int> b(100)/
Chapter 25
Chapter 26
- (+) pg 959: replace commas with spaces in the test input example.
- (+5/15/09) pg 956: s/different element at end/different element at beginning/ for the line with lots of 1s
- (+6/23/09) pg 960: s/rand_int/randint/ four times
- (+6/23/09) pg 960: 1/24.7:/24.7 and std_lib_facilities.h:/
- (+6/23/09) pg 961: s/rand_int/randint/ two times
- (+5/16/09) pg 972: s/from the "main program":/from the "main program"):/
- (+4/19/09) pg 980: s/earlier tests runs/earlier test runs/
- (+) pg 980: s/++n/++i/
- (+5/18/09) pg 984: s/different element at end/different element at beginning/ for the line with lots of 1s
- (+10/4/09) pg 985: in 1: s/26.2.1/26.3.2.1/
- (+8/27/09) pg 985: in 3: s/the exercise in sec26.2.1/exercise 1/
Chapter 27
- (+) pg 989: s/ARM C/ARM C++/
- (+) pg 989: s/C++99/C99/
- (+) pg 991: K&R is published by Prentice Hall, not Addison-Wesley.
- (+3/9/09) pg 996: s/The declaration of g() specifies no argument./The declaration of h() specifies no argument./
- (+11/16/09) pg 996: s/This does not mean that g()/This does not mean that h()/
- (+) pg 1006: s/(0)/(7)/
- (+) pg 1006: s/S1 a;/S2 a;/
- (+) pg 1006: s/S1* r = (S1*)&a;/S1* r = (S1*)&b;/
- (+4/9/09) pg 1013: s/std:string/std::string/
- (+7/19/09) pg 1014 : s/change 'd' in a to/change 'd' in aa to/
- (+5/20/09) pg 1019: s/write from/write to/
- (+8/31/09) p1027: s/initialize *p/initialize *lst/
- (+6/26/09) pp1030-1031: move the definition int count = 0; to the top of the function main().
In C89, declarations cannot come after statements in a block.
- (+6/18/09) pg 1031: s/"Hello, World"/"Hello World"/
Appendix A
- (+) pg 1049: s/bound to a reference/bound to a local or namespace reference/
- (+5/22/09) pg 1054: /A12/A.12/
- (+5/22/09) pg 1058: /Try to convert v into a D*/Try to convert p into a D*/
- (+4/23/09) pg 1064: Add to the first prargraph under the table:
"The comparisons <, <=, >, >= can also by used for pointers of the same type into the same object or array."
- (+4/23/09) pg 1064: s/and casting (type conversion)./, casting (type conversion)/, and comparison (==, !=, <, <=, >, and >=)./
- (+) pg 1065: s/sizeof(a)==sizeof(a[0])*max==sizeof(int)*max/sizeof(a); that is, sizeof(int)*max/
- (+8/31/09) p1075: s/sizof(int)/sizeof(int)/
- (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 initilize 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.
- (+) pg 1082: add bitfield sizes as on page 929.
Appendix B
- (+4/20/09) pg 1102: s/*p = --n;/*p++ = --n;/
- (+5/28/09) pg 1124: s/The make_pair function/The make_pair() function/
- (+4/20/09) pg 1132: s/s1 or s2/s or s2/
- (+4/20/09) pg 1139: s/for i>1;/for i>0;/
- (+4/19/09) pg 1141: s/value of s/value of p/ (twice)
- (+4/19/09) pg 1141: s/applies to s/applies to p/
- (+4/19/09) pg 1142: s/value of s is '%d'\n",x,s);/value of p is '%d'\n",x,p);/
- (+5/30/09) pg 1145: s/ungetch()s/ungetc()s/
Appendix C
- (+3/13/09) pg 1153: s/programming/Programming/ (in the URL)
- (+8/14/09) pg 1153: s/\Visual Studio 2005 Projects/\Visual Studio 2005\Projects/
- (+6/1/09) pg 1154: s/\Visual Studio 2005 Projects/\Visual Studio 2005\Projects/
Appendix E
- (+4/6/09) pg 1167: s/int h, int w/int w, int h/
- (+5/6/09) pg 1168: s/experiment number 17/experiment number 7/
- (+4/6/09) pg 1168: s/int h, int w/int w, int h/
- (+4/6/09) pg 1168: s/:Window(h,w,t)/:Window(w,h,t)/
(and no, this doesn't change the effect of the program,
but making the naming of variables consistent with the rest of the book makes the text less likely to confuse).
- (+6/24/09) pg 1170: s/"mole"/"move"/
Glossary
- (+) pg 1173: add: encapsulation - protecting something meant to be private (e.g. implementation details) from unauthorized access.
Bibliography
- (+5/5/09) pg 1178: s/Maddoc/Maddock/
Index
- (+) pg 1186: s/initialization of, 417,543/initialization of, 470,543,1076,1079/
- (+8/27/09) pg 1190: s/clock(), 981-983/clock(), 981-983, 1147-1149/
- (+5/5/09) pg 1210: s/Maddoc/Maddock/
- (+3/17/09) pg 1222: s/reserve(), 651-652, 717, 1111/reserve(), 651-652, 667, 717, 1111/
- (+4/22/09) pg 1233: s/Wheeler, David, 108, 785, 930/Wheeler, David, 108, 785, 916, 930/
Thanks
Thanks to people who reported problems and often suggested remedies:
Royer Alain, Tapani Alakiuttu, Petra Alm,
Cassian Braconnier,
Leo Carreon, Gunner Carstens, Steve Carter, Greg Cheong, Carlos E. Csiszer,
J.P. Delport, Dustin Dettmer,
Alessandro Gentilini,
Yaakov Eisenberg, Richard Elderton,
Eugene Feoktistov, Stephen Feyrer,
Alessandro Gentilini,
J.R. Halterlein, Christopher E. Harris, Carlos Hernandez, C.W.Holeman II,
Jagadish R., Daniel Joffe,
Nabil Kabbani, Christopher Keane, Prabhat Kiran, Chin-Yuan Kuo,
Dirk Louis, Michael Leuschel, Teresa Leyk,
Vinit Mahedia, Mark Millard, Sam Mitchell, Jaime Moreno,
Akira Nakamura,
Carlos Pantelides, Bob Parker, Bo Persson, Marcelo Pinto, Lukasz Piwko,
Alec Ross, Robert J. Ryan, Iver Roessum
David Spaniol,
Alan Talbot, Dennis Tang,
Kees Varekamp, Francisco Vidaller
Art Werschulz, Kah-Yat Isaac Wong, Yongning Wu.