From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Freeing static vars Date: Thu, 05 Feb 1998 23:53:43 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 20 Message-ID: <34DA9757.385C@cs.com> References: <3 DOT 0 DOT 5 DOT 32 DOT 19980205125943 DOT 007b3180 AT math DOT amu DOT edu DOT pl> NNTP-Posting-Host: ppp219.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Maciej Radziejewski wrote: > > Perhaps it is too obvious to write, but isn't this accomplished in C++ > by defining a local scope and declaring the variables inside it? > The variables will be destroyed upon leaving the local scope. Yes, but such variables are automatic, not static. Use of the term "static" implies a variable that remains throughout the duration of the program. By its very definition, a static variable cannot be deleted or freed. However, the data it contains can be modified, so if you define a static pointer, you could certainly free the memory it points to (assuming, of course, that you allocated some to begin with). -- --------------------------------------------------------------------- | John M. Aldrich | "It may be better to be a live jackal| | aka Fighteer I | than a dead lion, but it is better | | mailto:fighteer AT cs DOT com | still to be a live lion." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------