From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,56131a5c3acc678e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-03 23:15:29 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny01.gnilink.net.POSTED!53ab2750!not-for-mail From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031008 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question about OO programming in Ada References: <8urxb.19482$sb4.18182@newsread2.news.pas.earthlink.net> <1792884.HtYz4Yv8lY@linux1.krischik.com> <1070466281.168920@master.nyc.kbcfp.com> <1070490862.478119@master.nyc.kbcfp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 04 Dec 2003 07:15:28 GMT NNTP-Posting-Host: 162.84.211.17 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny01.gnilink.net 1070522128 162.84.211.17 (Thu, 04 Dec 2003 02:15:28 EST) NNTP-Posting-Date: Thu, 04 Dec 2003 02:15:28 EST Xref: archiver1.google.com comp.lang.ada:3124 Date: 2003-12-04T07:15:28+00:00 List-Id: Robert I. Eachus wrote: > Ah, I think I get it. In C there are many occasions where a function > will return a heap object, and it is up to the caller to free the > memory. The returned value can be a copy of the original pointer, so in > C it is relatively common to free a copy of the original heap pointer. > That may be what is confusing Hyman. I'm confused about whether I'm confused :-) Anyway, C++ doesn't set a pointer variable to null when you free its contents. Since you should be doing this in destructors most of the time, it doesn't matter, because the pointer variable will very shortly not exist. Now, as I said, in C++ sometimes objects will delete themselves: struct A { int refcount; void decr() { if (--refcount == 0) delete this; } // etc. };