[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: The great destroy mystery.
From: George Staikos <staikos () kde ! org>
Date: 2003-08-08 0:27:59
[Download RAW message or body]
On Thursday 07 August 2003 20:04, Gary Cramblitt wrote:
> In my object destructor, do I need to explicitly destroy object pointers
> declared as member variables and initialized with _new_ or not? I can't
> find any consistent info on this. The C++ FAQ says that such objects are
> "automagically" destroyed when the parent object is destroyed. Elsewhere
> in the same FAQ, it says that one _must_ call delete for every new. ??
> And if I explicitly destroy an object in my destructor, do I risk
> destroying an object that has already been destroyed, thereby causing
> havoc? "Thinking in C++" has the following statement with regard to
> _delete_:
You have to delete anything that you "new". With Qt, however, if you "new"
a QObject derived object and parent it appropriately, it will automatically
be deleted for you.
kspeakPart::kspeakPart()
{
m_process = 0;
}
> kspeakPart::~kspeakPart()
> {
> delete m_process;
> }
That's how it should look. You must initialise the pointer to 0 if you do
not immediately allocate it.
--
George Staikos
KDE Developer http://www.kde.org/
Staikos Computing Services Inc. http://www.staikos.net/
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic