homepage | C++ links | FAQ | technical FAQ | glossary | compilers | publications | TC++PL | D&E | bio | interviews | AT&T Research

Errata for 5th/15th printing of The C++ Programming Language

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

Errors and Clarifications


Chapter 1:

pg 13 s/(sec B.2)/(with a few minor exceptions; see sec B.2)/

Chapter 2:

Chapter 3:

Chapter 6: pg 134: s/``does p point to a valid object,''/ ``does p point to a valid object (assuming proper initialization),''/

Chapter 10:

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).

Chapter 11: 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
Chapter 13:

pg 335 s/const char[12]/const char v[12]/

Chapter 14:

pg 369 better:

        X* p3 = new(&buffer[10]) X;             // place X in buffer (no deallocation needed)
        X* p4 = new(&buffer[11]) X[10];
Chapter 18:

pg 538 replace the second example with

For a call random_shuffle(b,e,r), the generator is called with the number of elements in the sequence as its argument: r(e-b). The generator must return a value in the range [0,e-b). If My_rand is such a generator, we might shuffle a deck of cards like this:

        void f(deque< Card>& dc, My_rand& r)
        {
                random_shuffle(dc.begin(),dc.end(),r);
                // ...
        }
Chapter 20:

pg 599: replace the last two declarations with:

        size_t strspn(const char* p, const char* q);    // number of char in p before a char not in q
        size_t strcspn(const char* p, const char* q);   // number of char in p before a char in q
Appendix A:

Appendix B:

Appendix C:

pg 895 s/: num_put/std::num_put/

pg 898 s/my_numpunct/My_punct/

pg 910 add before D.4.4.4: A _byname version (D.4, D.4.1) of time_put is also provided:

        template < class Ch, class Out = ostreambuf_iterator< Ch> >
        class std::time_put_byname : public time_put< Ch,Out> { /* ... */ };
pg 912 s/time_put()/time_put::put()/ twice

pg 912 replace the last paragraph with: A _byname version (D.4, D.4.1) time_get is also provided:

        template < class Ch, class In = istreambuf_iterator< Ch> >
        class std::time_get_byname : public time_get< Ch,In> { /* ... */ };
pg 915 s/Date_format< char>::/Date_format::/

pg 918 s/dateorder()/date_order()/

pg 919 s/order = dateorder();/order = date_order();/

pg 919 s/tmp->tm_mday = val[1];/tmp->tm_mday = val[2];/

pg 924 s/widen(narrow('x')) == 'x'/widen(narrow('x'),0) == 'x'/

pg 926 s/out() encountered/in() encountered/

pg 928 add "char ch;" before the while-statement

Appendix D:

Appendix E:


Typos


Chapter 4: pg 80 s/a vector/an array/

Chapter 11: pg 288 s/ of the array/of the vector/

Appendix B:

pg 817 s/Direction d = 1;/enum Direction d = 1;/

homepage | C++ links | FAQ | technical FAQ | glossary | compilers | publications | TC++PL | D&E | bio | interviews | AT&T Research