home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!prism!federation!andy
- From: andy@federation.gatech.edu (Andy Register)
- Newsgroups: comp.lang.c++
- Subject: Re: Should char arrays be deleted with delete[]?
- Keywords: C++
- Message-ID: <78593@hydra.gatech.EDU>
- Date: 18 Dec 92 18:53:13 GMT
- References: <1992Dec18.161338.28124@promis.com>
- Sender: news@prism.gatech.EDU
- Organization: CERL-EE, Georgia Institue of Technology
- Lines: 25
-
- In article <1992Dec18.161338.28124@promis.com> fogel@promis.com (Richard Fogel) writes:
- >Should char strings allocated as follows:
- >
- >char *str = new char[10];
- >
- >later be deleted by:
- >
- >delete []str OR delete str ?
-
-
- To quote from Meyers, "In the case of an object type like char that has no
- destructor, this issue isn't important, but in general this is something
- you do not want to forget. *Always* make sure that you use [] with
- delete if and only if you used [] with the corresponding call to new."
-
- Item 11 btw.
-
- So, use either syntax for str but I would advocate using the [] syntax
- so that you get used to it and automatically use it in cases
- where it matters.
-
- Toodles
- Andy
-
-
-