delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/09/16:06:45

From: Laurence Withers <lwithers AT lwithers DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: "delete" and "delete []" operators
Date: Wed, 8 Jul 1998 23:40:59 +0100
Organization: Integrated Peripherals
Message-ID: <ivglrCA7V$o1Ew74@lwithers.demon.co.uk>
NNTP-Posting-Host: lwithers.demon.co.uk
MIME-Version: 1.0
Lines: 26
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,

In any programs I write, I always use the "delete" operator to free
memory I've allocated with the "new" operator. However, recently I've
read somewhere about the "delete []" operator, which should be used to
delete arrays.

If I create an array like this:

  typedef char *cptr;
  cptr x;
  x = new char[15];

Should I then, when I come to free the memory, use:

  delete x;
or
  delete [] x;

Currently, I use "delete x;".

Well, please tell if I'm doing something wrong. Thanks very much for
your help, and bye for now,
-- 
Laurence Withers, mailto:lwithers AT lwithers DOT demon DOT co DOT uk
OPES homepage:   http://www.lwithers.demon.co.uk/opes/

- Raw text -


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