home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18204 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.4 KB  |  43 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!news.encore.com!news!jpolito
  3. From: jpolito@sysgem1.encore.com (Jonathan Polito)
  4. Subject: Re: Should char arrays be deleted with delete[]?
  5. Organization: Encore Computer Corp.
  6. Date: Fri, 18 Dec 1992 18:53:29 GMT
  7. Message-ID: <JPOLITO.92Dec18135329@sysgem1.encore.com>
  8. In-Reply-To: fogel@promis.com's message of Fri, 18 Dec 1992 16:13:38 GMT
  9. References: <1992Dec18.161338.28124@promis.com>
  10. Sender: news@encore.com (Usenet readnews user id)
  11. Nntp-Posting-Host: sysgem1.encore.com
  12. Lines: 29
  13.  
  14.  
  15. In article <1992Dec18.161338.28124@promis.com> fogel@promis.com (Richard Fogel) writes:
  16.  
  17.    Should char strings allocated as follows:
  18.  
  19.    char *str = new char[10];
  20.  
  21.    later be deleted by:
  22.  
  23.    delete []str   OR    delete str  ?
  24.  
  25.    Thanks, this would be a great help, as the texts do not realy address this
  26.    issue, and I understand that the wrong delete approach will cause unexplained
  27.    results.
  28.  
  29.    Richard Fogel
  30.  
  31.  
  32. See the ARM 5.3.4: "The form delete [] cast-expression is used to
  33. delete arrays. The expression points to an array...The effect of
  34. deleting an array with the plain delete syntax is undefined, as is
  35. deleting an individual object with the delete [] syntax."
  36.  
  37. Now if only the InterViews folks would read the ARM.
  38.  
  39. --
  40. Jonathan E. Polito             Internet: jpolito@encore.com
  41. Encore Computer Corp, 901 Kildaire Farm Rd, Cary, NC  27511  USA
  42. 919-481-3730/voice                  919-481-3868/FAX
  43.