home | C++ | FAQ | technical FAQ | publications | WG21 papers | TC++PL | Tour++ | Programming | D&E | bio | interviews | videos | quotes | applications | guidelines | compilers

Errata for 7th/17th printing of The C++ Programming Language

Modified June 9, 2003

Errata for Bjarne Stroustrup: The C++ Programming Language (special edition), Addison-Wesley, 2000. ISBN0-201-70073-5. Errata for the 7th printing yielding the 8th printing. Also for the 17th printing of "The C++ Programming Language (3rd edition).


Errors and Clarifications


Chapter 1:

pg 6 s/C++ as defined in the C++ standard [C++,1998]/ C++ as defined in the C++ standard [C++,1998] [C++,2003]/

pg 11 s/The ISO C++ standard (ISO/IEC 14882) was ratified in 1998./ The ISO C++ standard (ISO/IEC 14882) was ratified in 1998. A Technical Corregendum, fixing minor errors and inconsistencies was issued in 2003 [C++,2003]./

pg 17 add [C++C,2003] X3 Secretariat: International Standard - The C++ Language (including the 2003 Technical Corrigendum). 14882:2003(E). Information Technology Council (NSITC). Washington, DC, USA.

Chapter 2:

Chapter 3:

pg 53 s/out_of_range/out_of_range (presented in < stdexcept>/

pg57 add

	bool operator==(const Entry& a, const Entry& b) { return a.name==b.name; }
	bool operator< (const Entry& a, const Entry& b) { return a.name< b.name; }

Chapter 4:

Chapter 6:

pg 117 here is a better version of the last paragraph: "A program starts by calling main() (sec3.2, sec 9.4). When this is done, main() is given two arguments specifying the number of arguments, usually called argc, and an array of arguments, usually called argv. These arguments are passed to main() from the environment that invokes the program; an environment that cannot pass arguments sets argc to 0. Because the conventions for calling main() are shared with C, an array of C-style strings (char* argv[argc+1]) is used. The name of the program (as it occurs on the command line) is passed as argv[0] . The list of arguments is zero-terminated; that is, argv[argc]==0 . For example, for the command"

Chapter 7:

Chapter 8:

Chapter 9:

Chapter 10:

Chapter 11:

pg 286 s/const_iterator p/iterator p/

Chapter 13:

Chapter 14:

pg 344 The implementation of Shell sort that I use in my examples has a performance bug. To fix that add the final "else break;"

	template< class T> void sort(Vector< T>& v)
	{
		const size_t n = v.size();

		for (int gap=n/2; 0< gap; gap/=2)
			for (int i=gap; i< n; i++)
				for (int j=i-gap; 0<=j; j-=gap)
					if (less(v[j+gap],v[j]))
						swap(v[j],v[j+gap]);
					else
						break;
	}

Chapter 16:

Chapter 17:

pg 465 s/For a vector, the element data structure is most likely an array like this:/For a vector, the element data structure is a contigously allocated sequence of elements, most likely an array like this:/

pg 488 s/Specifying a position, insert(pos,val), is simply a hint to the implementation to start the search for the key val at pos./ Specifying a position, insert(pos,val), is simply a hint to the implementation to start the search for the key val.first at pos./

pg 502 Move the "while(no_of_erased) loop below the "if(s<=b.size()) return;" statement

Chapter 18:

pg 509 replace the table entry for search_n by

	search_n()	Find n consecutive occurences of a value in a sequence.

pg 516 s/standard libraries and algorithms/standard library containers and algorithms/

pg 535 s/list< Club>/list< Person*>/

pg 539 s/The default comparison is less (sec 18.4.2), which in turn uses < by default./The default comparison is <./

pg 539 s/int operator()/bool operator()/

Chapter 19:

Chapter 20:

Chapter 21:

pg 617 s/and that no characters have been lost/(but characters may have been lost)./

pg 629 s/maximum// in the description of the "scientific" and "fixed" formats

pg 651 s/word(i)/pword(i)

pg 651 replace the last sentence of the first paragraph with "When the state changes, a registered function is called with the argument pword(i) where i was supplied by its register_callback()."

Chapter 22:

pg 687 s/Include x=0.5(x+y)+z among your test cases/Include x=0.5*(x+y)+z among your test cases/

Chapter 23:

pg 707 s/consideration of dependencies in Step 2./consideration of dependencies in Step 3./

pg 720 S/Miscasts C++ by describing it as it was ten years ago. /Miscasts C++ by describing 1987-vintage C++./

Chapter 24:

Chapter 25:

pg 767 replace the last example with

	template< class C> void ours(C& c)
	{
		for (typename C::iterator p = c.begin(); p!=c.end(); ++p) {  // standard library iteration
			// ...
		}
	}

Appendix A:

Appendix B:

Appendix C:

pg 860 s/nothing related to complex numbers/nothing related to Quad numbers/

pg 863 an improved version of the first example: "For example:

	struct X { X(int); /* ... */ };

	void g(X);

	template< class T> void f(T a) { g(a); }

	void h()
	{
		extern void g(int);
		f(2);	// invokes f(X(2)); that is, f< X>(X(2))
	} 
Here, the point of instantiation for f is just before h(), so the g() called in f() is the global g(X) rather than the local g(int)."

pg 865 replace the last paragraph of C.13.8.4 with "Built-in types do not have an associated namespace. Consequently, dependent name resolution do not provide overload resolution between declarations seen before and after a template definition For example:

	int f(int);

	void ff(int);
	void ff(char);

	template T g(T t) { ff(t); return f(t); }

	char f(char);

	char c = g('a');	// calls ff(char); calls f(int) -- f(char) is not considered
Obviously, such subtleties are best avoided."

Appendix D:

pg 893 replace the last two sentences of the middle paragraph with: "They also define the the format for the integer part of a floating point number, but not for the digits after the decimal_point()."

pg 894 replace the first example and its output with:

	void f()
	{
		cout << setprecision(4) << fixed;
		cout << "style A: " << 12345678 << " *** " << 1234.5678 << '\n';
		locale loc(locale(),new My_punct);
		cout.imbue(loc);
		cout << "style B: " << 12345678 << " *** " << 1234.5678 << '\n';
	}
This produced:
	style A: 12345678 *** 1234.5678
	style B: 12 345 678 *** 1 234,5678

Appendix E:


Typos


Chapter 4:

Chapter 12:

Chapter 17:

Appendix D:

Appendix E:

home | C++ | FAQ | technical FAQ | publications | WG21 papers | TC++PL | Tour++ | Programming | D&E | bio | interviews | videos | quotes | applications | guidelines | compilers