Here, I made a packet of all the erratas for the book "The C++ Programming Language (Special Edition)" from the first print of the Sepcial Edition, so it should cover all the erratas of the PhotoCopy Edition sold in China. While looking through these erratas, please ATTENTION Stroustrup's words:"For brevity, I use the old replacement syntax: s/old/new/".
- bood(boodweb@wx88.net)
- 2002/04/02
Errors and Clarifications
Chapter 1:
pg 13 s/(sec B.2)/(with a few minor exceptions; see sec B.2)/
Chapter 3:
pg 55 s/Entry& e =/const Entry& e =/
Chapter 4:
pg 76 A better version of the example:
#include < limits>
#include < iostream>
int main()
{
std::cout << "largest float == " << std::numeric_limits< float>::max()
<< ", char is signed == " << std::numeric_limits< char>::is_signed << '/n';
}
pg 77 Replace the 5th paragraph with: "An enumerator can be initialized by a constant-expression (C.5) of integral type (4.1.1). The range of an enumeration holds all the enumeration's enumerator values rounded up to the nearest larger binary power minus 1. The range goes down to 0 if the smallest enumerator is non-negative. If the smallest enumerator is negative, the range goes down to -(1+max) where max is the largests value in the positive part of the range. This defines the smallest bit-field capable of holding the enumerator values using the conventional two's complement representation. For example:"
Chapter 6:
pg 109-110: s/left=left+term() and left=left-term) could have been used without changing the meaning of the program. However, left+=term() and left-=term(/ left=left+term(true) and left=left-term(true) could have been used without changing the meaning of the program. However, left+=term(true) and left-=term(true)/
pg 125 s/The increment operators are particularly useful for incrementing and decrementing variables in loops./The ++ and -- operators are particularly useful for incrementing and decrementing variables in loops./
pg 129 Add comments to first example:
void* operator new(size_t); // allocate space for individual object
void operator delete(void* p); // if (p) deallocate space allocated using operator new()
void* operator new[](size_t); // allocate space for array
void operator delete[](void* p); // if (p) deallocate space allocated using operator new[]()
pg 130 s/an enumeration to an integral type/an integral type to an enumeration/
pg 131 Clarification of the first paragraph after the first example: "The T(e) construct is sometimes referred to as a function-style cast. Unfortunately, for a built-in type T, T(e) is equivalent to (T)e (6.2.7). This implies that for many built-in types T(e) is not safe. ..."
pg 131 s/removing const qualifiers/removing const and volatile qualifiers/
pg 134: s/``does p point to a valid object,''/ ``does p point to a valid object (assuming proper initialization),''/
Chapter 7:
pg 146 s/21.2.1/21.3.2/
Chapter 8:
pg 193 add "++Driver::no_of_errors;" to each catch clause
pg 195 s/depending on where in a class stack/ depending on where in the function call stack/
Chapter 9:
pg 202: Improved last example:
#ifdef __cplusplus // for C++ compilers only (9.2.4)
namespace std { // the standard library is defined in namespace std (8.2.9)
extern "C" { // stdio functions have C linkage (9.2.4)
#endif
/* ... */
int printf(const char*, ...);
/* ... */
#ifdef __cplusplus
}
}
// ...
using std::printf; // make printf available in global namespace
// ...
#endif
Chapter 10:
pg 246 Replace the last sentence before 10.4.5 by: "Exceptions can be used to report failure to copy (14.4.6.2). See E.3.3 for techniques for writing exception-safe copy operations."
pg 247 s/reverse order of construction./reverse order of construction after the body of the class' own destructor has been executed./
pg 251 replace the middle example with
void g()
{
vector< Table> v(10); // no need for a delete
vector< Table>* p = new vector< Table>(10); // use plain "delete" rather than "delete[]"
delete p;
}
Using a container, such as vector, is simpler than writing a new/delete pair. Furthermore, vector provides exception safety (Appendix E).
pg 258 s/10.4.6.1/10.4.6.2/
Chapter 11:
pg 265 s/basic type/built-in type (sec4.1.1)/
pg 273 s/basic type/built-in type/
pg 275 s/basic type/built-in type/ twice
pg 280 add the sentence "Scopes outside the innermost enclosing namespace scope are not considered." before the first "For example:" and replace the first example by:
class AE { /* ... */ }; // not a friend of Y
namespace N {
class X { /* ... */ }; // Y's friend
class Y {
friend class X;
friend class Z;
friend class AE;
};
class Z { /* ... */ }; // Y's friend
}
pg 280 Improved version of 4th paragraph: "Thus, a friend function should be explicitly declared in an enclosing scope or take an argument of its class or a class derived from that (13.6). If not, the friend cannot be called. For example:"
pg 284 s/string initialized (using copy constructor)/string initialized (using constructor)/
pg 288 s/return b;/return f;/
pg 290 replace the example using Y at the middle of the page by: Given a class Y for which ->, *, and [] have their default meaning and a Y* called p then
p->m == (*p).m // is true
(*p).m == p[0].m // is true
p->m == p[0].m // is true
pg 293 better:
class String {
struct Srep; //