| delorie.com/archives/browse.cgi | search |
| Newsgroups: | comp.os.msdos.djgpp |
| From: | manni DOT heumann AT gmx DOT de (Manni Heumann) |
| Subject: | Re: strdup() with delete[] |
| References: | <F82wV0zqedbDoW8JHY90000922c AT hotmail DOT com> |
| X-Newsreader: | News Xpress 2.01 |
| Mime-Version: | 1.0 |
| Date: | Mon, 11 Sep 2000 11:22:51 GMT |
| NNTP-Posting-Host: | dhcp33-228.uni-bielefeld.de |
| Message-ID: | <39bcc089$1_1@news.uni-bielefeld.de> |
| X-Trace: | 11 Sep 2000 13:22:49 +0200, dhcp33-228.uni-bielefeld.de |
| Lines: | 29 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Nimrod Abing wrote:
>>class Test {
>>public:
>> Test () { cout << "Constructing\n"; }
>> ~Test () { cout << "Destructing\n"; }
>>};
>>
>>int main () {
>> Test *t = new Test [3];
>> delete t;
>
>In a real world scenario, this would be a fatal mistake since the
>destructor would only be called for t[0]. The correct form would be:
>
> delete [] t;
>
>> return 0;
>>}
That's why I provided that example! It clearly shows that
delete[] is far form being obsolete.
--
Manni
"Life would be much easier if I had the source code."
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |