From: Hyman Rosen <hymie@prolifics.com>
Subject: Re: More questions...
Date: 1999/03/09
Date: 1999-03-09T22:13:01+00:00 [thread overview]
Message-ID: <36E59D1A.65ADB66E@prolifics.com> (raw)
In-Reply-To: 7c40uu$14lu@news3.newsguy.com
Samuel Mize wrote:
> OTOH, when you assign a new value to an object with a destructor, does
> C++ call the destructor before assigning the new value? Or is that even
> a meaningful question for C++?
In C++ classes may have user-defined assignment operators. If a class has
such a thing, then it is invoked when the assignment is done, and it is
responsible for doing the necessary cleanup work. If a class does not have
a user-defined assignment operator, then the default behavior is to treat
assignment as a field-by-field copy, recursively invoking other user-defined
assignment operators if fields are themselves class objects.
Note that in C++, assigning to an object does not have the semantics of
destroying the object and replacing it with a new one. The object is
considered to be the same before and after the assignment. It merely has
had its value changed in some fashion.
next prev parent reply other threads:[~1999-03-09 0:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-07 0:00 More questions Michael Young
1999-03-08 0:00 ` James S. Rogers
1999-03-08 0:00 ` Hyman Rosen
1999-03-10 0:00 ` Matthew Heaney
1999-03-08 0:00 ` Steve Doiel
1999-03-09 0:00 ` Samuel Mize
1999-03-09 0:00 ` Samuel Mize
1999-03-09 0:00 ` Hyman Rosen [this message]
1999-03-10 0:00 ` robert_dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox