delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/27/23:21:59

Message-Id: <3.0.6.32.19990227232144.008a0450@pop.globalserve.net>
X-Sender: derbyshire AT pop DOT globalserve DOT net
X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32)
Date: Sat, 27 Feb 1999 23:21:44 -0500
To: djgpp AT delorie DOT com
From: Paul Derbyshire <pderbysh AT usa DOT net>
Subject: Re: destructors for C++ classes.
In-Reply-To: <36d7c7dc.49356683@news.uea.ac.uk>
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

At 10:36 AM 2/27/99 GMT, you wrote:
>        vector<string> words;

The vector deals with its own destruction. you would only need a

delete [] words

if you had used your own dynamic allocation, with

  string *words;

...

  (in constructor)
  words = new string[some_number];


As it is you don't need any destructor in that class since you don't have
any dynamically allocated pointer members. (The vector's destructor deals
with that and is called automatically.)
Also, you almost never need to explicitly call a destructor.
-- 
   .*.  "Clouds are not spheres, mountains are not cones, coastlines are not
-()  <  circles, and bark is not smooth, nor does lightning travel in a
   `*'  straight line."    -------------------------------------------------
        -- B. Mandelbrot  |http://surf.to/pgd.net
_____________________ ____|________     Paul Derbyshire     pderbysh AT usa DOT net
Programmer & Humanist|ICQ: 10423848|

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019