🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #452

Re: Program crashes at end

#452
From: gbayles
Date: Tue, 28 May 2002 13:10
29 lines
1725 bytes
"SKAS" <f93c0532@yahoo.com> wrote in message news:<acv9rh$sopon$1@ID-31123.news.dfncis.de>...
> I've written a class for string datatype.  

Presumably as a learnng exercise.

> ... The program runs fine but crashes in the end.

IME, this usually means the dtor is accessing invalid memory.

> class string
> {
>  private:
>       char *head;
>       int len;
>  public:
>       string()
>    {
>    }

Always initialize member variables in every ctor. This one allows
you to declare a string with unpredictable values for head and len.
 
>   ~string()
>   {
>      delete head;
>   }

So it can blow up here when the object is destroyed as the program
exits.
Technical Details
Message-ID: <82ebdb39.0205280510.12c48abf@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
References: <acv9rh$sopon$1@ID-31123.news.dfncis.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 114592,807a736b2ed72881
X-Google-Attributes: gid114592,public
X-Google-Thread: 114af8,807a736b2ed72881
X-Google-Attributes: gid114af8,public
X-Google-Thread: 109fba,807a736b2ed72881
X-Google-Attributes: gid109fba,public
X-Google-ArrivalTime: 2002-05-28 06:10:24 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
From: gbayles2001@yahoo.com (gbayles)
Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.turbocpp,comp.lang.c++
Subject: Re: Program crashes at end
Date: 28 May 2002 06:10:24 -0700
Organization: http://groups.google.com/
Lines: 29
Message-ID: <82ebdb39.0205280510.12c48abf@posting.google.com>
References: <acv9rh$sopon$1@ID-31123.news.dfncis.de>
NNTP-Posting-Host: 65.115.221.98
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1022591424 8640 127.0.0.1 (28 May 2002 13:10:24 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 28 May 2002 13:10:24 GMT