[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: question about "new" and "delete" ?
From: |
Thomas Maeder |
Subject: |
Re: question about "new" and "delete" ? |
Date: |
Sun, 06 Mar 2005 08:33:41 +0100 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> writes:
> To prevent the problem, I always follow
> a delete by clearing the pointer:
>
> delete [] a;
> a = 0;
>
> Your cout will then result in an immediate, and obvious
> crash, which can then be debugged.
IMHO, better advice would be to not express ownership of a dynamically
allocated resource through a "raw" pointer. Smart pointers are much
better suited to that task.
Re: question about "new" and "delete" ?, Thomas Maeder, 2005/03/06