Last modified 10 June 2008express
Every book has bugs in it, and C++ Primer is no exception. This page presents all the bugs that have come to our attention. All of these errors are corrected in the Ninth printing, July 2008. Many thanks to the careful readers who notified us of these problems!app
Page 182: The code fragment in the section Conversions and Enumeration Types should refer to point2w not pt2w:curl
int chunk_size = array_size * point2w;
not:ide
int chunk_size = array_size * pt2w;
Page 241: The first code fragment in Passing a Multidimensioned Array is incorrect. It should read:oop
void printValues(int (*matrix)[10], int rowSize);
not:fetch
void printValues(int (matrix*)[10], int rowSize);
Page 455: The constructor initializers in the constructor definition at the bottom of the page should be:ui
ConstRef::ConstRef(int ii): i(ii), ci(ii), ri(i) { }
Pages 763: The second for loop incorrectly ommitted the decrement on the pointer p. It should read:this
(--p)->~T(); // call the destructor
not:url
p->~T(); // call the destructor
Page 276: The parameters in the first declaration in Exercise 7.39 part (a) should be references:spa
int calc(int&, int&);
not values:
int calc(int, int);
Page 567: Change Exercise 15.5 (b) to:
class Derived : public Base { ... };
The exericse as originally written required the reader to understand that the access_label is optional. However, this fact is not covered until Section 15.2.5.
Page 571: In Exercise 15.8, the print function in class derived is incorrect. It should be:
void print(ostream &os) { print(os); os << " " << mem; }
not
void print() { print(ostream &os); os << " " << mem; }
Also, in Exercise 15.9, the initializations of bp1 and bp2 are incorrect. They should be:
base *bp1 = &bobj; base *bp2 = &dobj;
not
base *bp1 = &base; base *bp2 = &doboj;