Article View: de.comp.lang.c++
Article #32Re: Errata fuer Stroustrup, 2.Auflage?
From: Jan Schiefer
Date: Mon, 17 Aug 1992 19:16
Date: Mon, 17 Aug 1992 19:16
296 lines
9253 bytes
9253 bytes
jh@first.gmd.de (Joerg Heuer) schreibt:
> Helfen kann ich Dir leider auch nicht, aber Dein Errata interessiert mich.
> (Ich habe die Original-Ausgabe, durch "ubersetzen wird's nur noch schlimmer.)
Die Uebersetzung ist sprachlich recht ordentlich, aber es sind doch einige
Ungenauigkeiten drin. Mir schien die Kombination Stroustrup (deutsch) und
Annotated Reference Manual (englisch) ideal zu sein, und es bewaehrt sich.
> Hast Du das in File-Form, so dass Du es mir mailen, oder bei Interesse, an
> diese Newsgroup posten, k"onntest?
Bei dem grossen Volumen dieser Gruppe ist Posten wohl verantwortbar :-).
Hier kommt's:
----------------------------------------------------
> From: bs@alice.att.com (Bjarne Stroustrup)
> Newsgroups: comp.lang.c++
> Subject: Re: Is there an errata for 2nd edition Stroustrup C++ book?
> Summary: yes
> Message-ID: <20983@alice.att.com>
> Date: 1 Oct 91 20:05:01 GMT
> Organization: AT&T Bell Laboratories, Murray Hill NJ
> Lines: 264
Here is an errata list for the 1st printing of the 2nd edition of
Bjarne Stroustrup: The C++ Programming Language, Addison Wesley, 1991.
The corrections here covers program bugs and stylistic issues in the
program fragments, but not simple typos in the text. I am grateful
to all that have pointed out problems to me.
For brevity I have used the old ed syntax: s/old-text/new-text/
Item marked with * wasn't in my previous errata posting.
pg25,29,99,194 s/stream.h/iostream/
pg39 s/cs.pop()/s.pop()/
pg64,99,116,119 s/main()/int main()/
pg71 s/unsigned/unsigned int/ in struct sreg
pg85,86,87 s/"\n"/'\n'/
pg99 #include <stdlib.h> (to get the declaration of exit())
pg112 s/struct S { int a; char b; }/struct S { int a; char b; };/
pg116,118 s/const TBLSZ/const int TBLSZ/
*pg141 s/r.8.5/r.9.3/
*pg152 s/delete s;/delete[] s;/
*pg156 s/delete n->string;/delete[] n->string;/
pg158 main() should be
int main(int argc, char *argv[])
{
if (argc != 3) error("two arguments expected");
int count = 0;
int m = atoi(argv[1]); // number of set members
int n = atoi(argv[2]); // in the range 1..n
intset s(m,n);
while (count<m) {
int t = randint(n);
if (s.member(t)==0) {
s.insert(t);
count++;
}
}
print_in_order(&s);
}
*pg159 s/delete x;/delete[] x;/
Pg170 function error(): name the arguments a1,a2, and a3
pg191 s/rotate::shape/shape::rotate/
pg191 s/rotate::draw/shape::draw/
pg193 s/class character_device {/class character_device { public:/
pg195 delete first definition of on_screen(). (it is a duplicate)
pg197 s/point sw, ne;/class rectangle : public shape { point sw, ne;/
pg203 s/pending()/pending();/
pg204 for dip, dip1, and dip2 s/debug_info/debug_info*/
pg204 s/dip.merge/dip->merge/
pg205,206 s/mamager::/manager::/
pg208 s/from the work done from the base class./from the work done from the derived class./
pg210,211 s/: public virtual window public window_w_input/: public virtual window, public window_w_input,/
*pg218 s/void copy(expr* s);/void copy(expr* s, deep = 0);/
*pg219 s/left = s->clone(1);/left = s->left->clone(1);/
*pg219 s/right = s->clone(1);/right = s->right->clone(1);/
*pg220 s/conditional::copy(expr* s, int deep)/conditional::copy(conditional* s, int deep)/
pg228 s/ivate:/private:/
pg229 s/trivially handled using friend functions/trivially handled using nonmember functions/
pg231 s/return this;/return *this;/
*pg237 s/delete p;/delete[] p;/
*pg241 s/max = (s<16) ? s : 16;/max = (s<16) ? 16 : s;/
pg243 s/assoc* cs;/const assoc* cs;/
pg262 s/insert(T&/insert(const T&/
pg262 s/append(T&/append(const T&/
pg262 s/lnk.info/lnk->info/
pg263 s/lst1.insert(*p)/lst1.insert(p)/
pg265 the declaration of Isplist should be
template<class T>
class Isplist : private slist_base {
public:
void insert(T* p) { slist_base::insert(p); }
void append(T* p) { slist_base::append(p); }
T* get() { return (T*) slist_base::get(); }
};
pg277 the declaration of the sort function should be
template<class T, class Comp> void Sort<T,Comp>::sort(Vector<T>& v)
{
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;
}
}
pg280 the examples should be
template<class T> void f1(T); // fine
template<class T> void f2(T*); // fine
template<class T> T f3(int); // error
template<int i> void f4(int[][i]); // error
template<int i> void f5(int = i); // error
template<class T, class C> void f6(T); // error
template<class T> void f7(const T&, complex); // fine
template<class T> void f8(Vector< List<T> >); // fine
pg306 s/mp.debug_print()/m.debug_print()/
pg306 first paragraph s/Int_overflow's debug()/Int_overflow's debug_print()/
pg329 s/"("/'('/ s/","/','/ s/")"/')'/
pg335,336 s/,istream&,ostream&)/,cin,cout)/
pg340,341,342 s/10.4.2.7/10.4.2.1/
pg346,347 s/return f(os,i)/return m.f(os,m.i)/
pg355 the declarations of strambuf and filebuf should be
class streambuf { // manage a stream buffer
protected:
char* base; // start of buffer
char* pptr; // next free char
char* gptr; // next filled char
char* eptr; // one off the end of buffer
char alloc; // buffer allocated by "new"
// ...
// Empty a buffer:
// Return EOF on error, 0 on success
virtual int overflow(int c =EOF);
// Fill a buffer:
// Return EOF on error or end of input,
// next char otherwise
virtual int underflow();
// ...
public:
streambuf();
streambuf(char* p, int l);
virtual ~streambuf();
int snextc() // get the next char
{
return (++gptr==pptr) ? underflow() : *gptr&0377;
}
int allocate(); // allocate some buffer space
// ...
};
class filebuf : public streambuf {
protected:
int fd; // file descriptor
char opened; // file opened
public:
filebuf() { opened = 0; }
filebuf(int nfd, char* p, int l)
: streambuf(p,l) { /* ... */ }
~filebuf() { close(); }
int overflow(int c =EOF);
int underflow();
filebuf* open(char *name, ios::open_mode om);
int close() { /* ... */ }
// ...
};
*pg409 s/C(int i)/C2(int i)/
*pg409 s/~C()/~C2()/
*pg410 s/C(X* q)/C3(X* q)/
*pg410 s/C(X& q)/C4(X& q)/
*pg418 add `int size() { return sz; }' as a public mermber of String
pg419 s/Assert(i<0 && i<s.size()/Assert(0<=i && i<size()/
pg435 s/: private array/: private vector/
pg438 add `virtual ~iter();' to the declaration of class iter
pg438 s/istream& is/istream& is;/
*pg453 s/operator[](int)/operator[](int);/
pg467 s/Map<void*,void(*)()> m;/Map<void*,void(*)(void*)> m;/
pg472 s/, count(new int)/, pcount(new int)/
pg473 the declaration of class X should be
class X {
static Pool my_pool;
// ...
public:
// ...
void* operator new(size_t) { return my_pool.alloc(); }
void operator delete(void* p) { my_pool.free(p); }
};
Pool X::my_pool(sizeof(X));
pg473 s/class Link/struct Link/
pg474 the definition of the constructor should be
Pool::Pool(unsigned sz)
: esize(sz)
{
head = 0;
}
pg474 s/const overhead = 12/const int overhead = 12;/
in the index: every reference to the manual proper refers
to page n where it should refer to page n-1
People have been polite enough not to inquire how so many errors
could creep in. In the case of most non-stylistic bugs, the answer
is in trouble with the software that inserts fragments of the tested
code examples into the text.
----------------------------------------------------
Gruss,
Jan
--
Jan Schiefer, DL5UE, jan@nasobem.stgt.sub.org
"Oracle et laboracle!" - Fritz Hohl
Technical Details
Message-ID:
<72962.920817@nasobem.stgt.sub.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!wupost!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!smurf.sub.org!nadia!delos!nasobem!janShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!smurf.sub.org!nadia!delos!nasobem!jan From: jan@nasobem.stgt.sub.org (Jan Schiefer) Newsgroups: de.comp.lang.c++ Subject: Re: Errata fuer Stroustrup, 2.Auflage? Message-ID: <72962.920817@nasobem.stgt.sub.org> Date: Mon, 17 Aug 92 19:16:03 GMT Distribution: world Lines: 296