This is for the first year.  Also available are errata for printings 1, 6, and 9.
Errata for

Bjarne Stroustrup:
The C++ Programming Language (2nd edition)

Addison-Wesley, 1991, ISBN0-201-53992-6, first year.
Here is about a year's worth of errata for
The C++ Programming Language (Second edition)
Thanks to all who sent me comments.  I am only able to correct minor problems.  Sorry.  Adding new sections, examples, and introducing new topics can only be done for new editions and not between printings.

Comments of all sorts both on the book and this errata are welcome.

- Bjarne Stroustrup (
I have posted some of this errata before, but I thought it useful for some to have it all together.  In several case, I have simply listed the corrected text (leaving you to find the original error).  In other cases I have used the old ed substitute syntax: s/old/new/

Pg79  Add to first paragraph:
Declaring a variable in a switch case requires the introduction of a block to indicate the scope of that variable. This prevents the variable from being used in another case where its initialization would have been by-passed; see also sec r.6.7.

and add { } around case DIV on page 78 and case LP on page 79.

pg 80 and pg82  remove
(operator >> is quite capable of skipping whitespace without explicit help from the programmer).

pg80  the correct declaration of look is:

pg89  use .* and ->* int the third column for .* and ->*, respectively.

pg90  add line
just above the comma(sequencing) line.

pg98  s/arg[1]/argv[1]/

pg100  add
to the statement production.

pg119  add to syn.c:

pg124  inline fac(int n) { return n<2? 1 : n*fac(n-1); }

pg 131  print(f); // float to double promotion: invoke print(double)

pg159  s/delete x;/delete[] x;/

pg166  s/task_chain/chain/ thrice

pg194  s/<stream.h>/<iostream.h>/

pg214  add argument lists to f():
    class Z2 : public Y2 { void f(Y1*, Y2*, Y3*); };

    class Y3 : private X { void f(Y1*, Y2*, Y3*); };
pg215  add ; after last } on page.

pg218-220  corrected lines:
    void copy(expr* s, int deep = 0);

    void expr::copy(expr* s, int deep)

    left = s->left->clone(1);
    right = s->right->clone(1);

    class conditional : public expr {

    void copy(conditional* s, int deep = 0);

    void conditional::copy(conditional* s, int deep)
pg242  s/delete vec;/ delete[] vec;/

pg245  s/so that the Record type/so that the Rec type/

    char& string::operator[](int i)
        if (i<0 || strlen(p->s)<i) error("index out of range");
        if (p->n>1) { // clone to maintain value semantics
            srep* np = new srep;
            np->s = new char[ strlen(p->s)+1 ];
            strcpy(np->s, p->s);
            p = np;
        return p->s[i];
pg266  slink* slist_base::get()

pg267  inline slink* operator()();

    template<class T> T* Slist_iter<T>::operator()()
            Tlink<T>* lnk = (Tlink<T>*) slist_base_iter::operator()();
            return lnk ? &lnk->info: 0;
    void f(name* n)
            Islist<name> lst1;
            Slist<name> lst2;

            // ...

            Islist_iter<name> iter1(lst1);
            const name* p;
            while (p=iter1()) {
                    Slist_iter<name> iter2(lst2);
                    const name* q;
                    while (q=iter2()) {
                    if (p == q) cout << "found " << *p << '\en';
pg274  add } at end of f()'s definition

pg 276 By wrapping the sort() function in a class we can allow the
Comparator to be specified directly:
    template<class T, class Comp> class Sort {
        static void sort(Vector<T>&);

    template<class T, class Comp>
    void Sort<T,Comp>::sort(Vector<T>& v)
        unsigned int n = v.size();

        for (int i=0; i<n-1; i++)
            for (int j=n-1; i<j; j--)
                if (Comp::lessthan(v[j],v[j-1])) {
                    T temp = v[j];
                    v[j] = v[j-1];
                    v[j-1] = temp;
We can now select the appropriate sort() by qualifying it with a Sort class with appropriate element and comparator types:
    void f(Vector<int>& vi,
           Vector<String>& vc,
           Vector<int>& vi2,
           Vector<char*>& vs)
        Sort< int,Comparator<int> >::sort(vi);
        Sort< String,Comparator<String> >::sort(vc);
        Sort< int,Comparator<int> >::sort(vi2);
        Sort< char*,Comparator<char*> >::sort(vs);
This last variant is a powerful model for composition of code from separate parts. The example can even be further simplified by using the comparator type as the only template argument:
    template<class Comp> class Sort {
        class Comp::T; // Comp must have a member type T
        static void sort(Vector<Comp::T>&);
The sort() function will sort any Vector that Comp can compare elements of:
    void f(Vector<int>& vi,
           Vector<String>& vc,
           Vector<int>& vi2,
           Vector<char*>& vs)
        Sort< Comparator<int> >::sort(vi);
        Sort< Comparator<String> >::sort(vc);
        Sort< Comparator<int> >::sort(vi2);
        Sort< Comparator<char*> >::sort(vs);
This implies that the comparator must give a name to its element type
        template<class T> class Comparator {
            typedef T T; // define Comparator<T>::T
            static int lessthan (T& a, T& b) {
                return a < b;
            // ...
so that Sort<Comp>::sort() can refer to the element type as Comp::T.

pg310  add private member
to class X.

pg338  cin.tie(&cout)

pg339  cout << '(' << 12 << "),(" << 12 << ")\n;"

pg345  ostream& operator<<(ostream& (*)(ostream&));
istream& operator>>(istream& (*)(istream&));

pg346  s/four digits after the point./four digits./

s/Omanip& m/Omanip_int& m/

s/_set_// twice

pg350  int peek();

pg351  if (mystream.bad()) {

pg352  for completeness add
before (or after)

pg409  in C2: s/C/C2/ twice
pg410  in C3: s/C/C3/ in C4: s/C/C4/

To track new developments, both the Annotated Reference Manual and Bjarne Stroustrup's book have an identical ``extra'' chapter that is updated a couple of times a year.  Its most recent version and the most recent errata sheet are available from Software, Tool & Die's ftp server in directory AW/stroustrup2e.
Thanks to Bjarne Stroustrup ( for errata and pointer.
Markup, etc. by, corrections and comments welcomed.