Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!apple.apple.com!scott From: scott@apple.apple.com (scott douglass) Newsgroups: comp.lang.c++ Subject: Re: Possible error in Stroustrup ? Message-ID: <2233@internal.Apple.COM> Date: 6 Jun 89 17:11:39 GMT Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 20 References:<774@batserver.cs.uq.oz> <10330@socslgw.csl.sony.JUNET> In article <10330@socslgw.csl.sony.JUNET> diamond@diamond.csl.sony.junet (Norman Diamond) writes: > In article <774@batserver.cs.uq.oz> anthony@batserver.cs.uq.oz writes: > > >On page 205 of "The C++ programming language" by Stroustrup, there is > >listing of a get function for circular list class slist. > > ... > >The line starting with "last = ...." seems to be wrong. > >... Can anyone confirm this ? > > Looks to me like it was a bug, and it looks to me like it looked to > Bjarne Stroustrup like it was a bug, too. On the same page is a bug the definition of slist::clear(). (My copy of The Book is "Reprinted with corrections July, 1987"). The function operator deletes all of the elements in the list but fails to clear the pointer to the last element (thus leaving the deleted elements in the list). Just add the line last = 0; as the last statement in slist::clear().