Errata for 1st printing of The C++ Programming Language

Errata for Bjarne Stroustrup: The C++ Programming Language (3rd edition), Addison-Wesley, 1997. ISBN0-201-88954-4. Errata for the 1st printing yielding the 2nd printing.

Errors and Clarifications

Chapter 2:

pg 25 s/try/tries/ several times in accept3()

pg 25 add ``return false;'' as the last statement of accept3()

pg 40 s/T* p;/T* v;/

Chapter 3:

pg 51 s/cin.getline/getline/

pg 56 swap "vector" and "list" in the declaration of f()

pg 56 s/copy_unique/unique_copy/

pg 57 swap "vector" and "list" in the declaration of f()

pg 57 s/copy_unique/unique_copy/

pg 62 s/void record(string&/void record(const string&/

pg 62 s/void print(pair<string,/void print(const pair<const string,/

pg 62 s/void main/int main/ (how do you make a gross mistake like that? You rename an ordinary function to 'main' and then check with a faulty compiler)

pg 62 s/sort(histogram.begin(),histogram.end());//

pg 62 s/The sorting isn't really necessary .../ Note that we don't need to sort the map to get the output in order. A map keeps its elements ordered so that an iteration traverses the map in (increasing) order./

pg 62 s/bool gt_42(pair<string/bool gt_42(const pair<const string/

pg 63 s/void g(map/void g(const map/

pg 64 s/<algo>/<algorithm>/

Chapter 6:

pg 123 In the 3rd paragraph, the sentence about short-circuit evaluations should read: For built-in types, the second operand of && is evaluated only if its first operand is true, and the second operand of || is evaluated only if its first operand is false; this is sometimes called short-circuit valuation.

Chapter 7:

pg 145 s/void main/int main/

Chapter 10:

pg 233 compute_cache_value() should be a const member function

Chapter 11:

pg 275 s/void main/int main/

Chapter 16:

pg 443 s/::types// twice

pg 443 s/return p;/return s;/

Chapter 18:

pg 533 s/sort(ls().begin(),ls.end());/ls.sort();/

Chapter 19:

pg 553 s/<iterators>/<iterator>/

pg 556 s/an insert_iterator inserts/an inserter inserts/

pg 556 s/using insert()/using push_back(), push_front(), or insert()/

pg 556 s/Clearly, an insert_iterator is an output iterator./Clearly, inserters are output iterators./

pg 558 s/ostream_iterator operator++(int)/ostream_iterator& operator++(int)/ (recent standard change)

pg 558 s/os =7/*os = 7/ twice

pg 559 s/character_traits/char_traits/

pg 560 s/char_traits<Tr>/char_traits<Ch>/

pg 560 s/operator*()/Ch operator*()/

pg 560 s/class ostreambuf_iterator :/class ostreambuf_iterator : public/

pg 565 The begin() and end() membet functions lack a closing }

pg 576 s/delete(void* p)/delete(void* p, void*)/

pg 577 In the paragraph starting ``Like strcpy()'' swap memcpy() and memmove()

Chapter 20:

pg 586 s/string s7(s3,3,2)/string s7(s5,3,2)/

Chapter 21:

pg 607 s/and a locale/and containing a locale/

pg 612 s/<iostream>/<ostream>/

pg 613 s/<iostream>/<istream>/

pg 649 add default constructor locale(); // copy of current global locale

pg 649 add copy constructor and copy assignment

pg 650 s/get space for a "word" for a pointer or integer/ get space for a pointer and an integer (both initialized to 0)/

pg 650 s/access word(i) as interger/access the integer iword(i)/

pg 650 s/access word(i) as pointer/access the pointer pword(i)/

pg 651 add to the sentence about sync_with_stdio: a call sync_with_stdio(false) before the firt stream I/O operation prevents buffer sharing and can improve I/O performance on some implementations.

pg 654 change [5] to: Remember that by default >> skips whitespace; sec21.3.2.

pg 654 add to [26]: use sync_with_stdio(false) to disconnect C-style and C++-style I/O.

Appendix A:

pg 794 add 'export' to list of keywords

Appendix B:

pg 820 s/c_plusplus/__cplusplus/



pg vi s/Joeseph/Joseph/

Chapter 1:

pg 12 s/Macinctosh/Macintosh/

pg 14 s/If don't already know/If you don't already know/

pg 15 s/eliminate of localize/eliminate or localize/

pg 17 s/Gamma,1994/Gamma,1995/

Chapter 3:

pg 56 s/multimap<key,val/multimap<key,val>/

Chapter 4:

pg 78 s/point/Point/ twice

Chapter 5:

pg 93 s/i = 2/i1 = 2/ in comment

pg 94 s/paramenters/parameters/

pg105 s/cons unsigned/const unsigned/

Chapter 10:

pg 242 s/sec3.7.1/sec3.7.2/

Chapter 15:

pg 419 s/variable of a/variable or a/

Chapter 16:

pg 429 s/sec15.4.1/sec15.4/ Chapter 19:

pg 555 s/rev_helper/dist_helper/

pg 555 s/void f(list<int>/void f(vector<int>/

pg 556 s/void g(list<int>/void g(vector<int>/

pg 557 s/};/}/

pg 565 s/become invalid/may become invalid/

pg 575 s/of type T/of type X/