[comp.lang.c++] New/Delete vs. Constructors/Destructors

s_johnson@csc32.enet.dec.com (Scott Johnson) (05/11/91)

Hi,

I have a question that has probably been asked before.  If it has can someone
forward me any information they have.

When creating and destroying objects, is it better to use the new/delete
operators or is it better to explicitly call the constructors/destructors
themselves?  Why is one method better than the other?

Thanks for any and all replies.


-------------------------------------------------------------------

        Scott Johnson
        Digital Equipment Corporation
        Colorado Springs, Co

steve@taumet.com (Stephen Clamage) (05/12/91)

s_johnson@csc32.enet.dec.com (Scott Johnson) writes:

>When creating and destroying objects, is it better to use the new/delete
>operators or is it better to explicitly call the constructors/destructors
>themselves?  Why is one method better than the other?

If I understand what you are asking, it is the same question as "Is it
better to have static/auto objects, or to allocate them on the heap?"
When you use new/delete, the constructor/destructor is called as part of
the operation.  The only questions are whether you want objects with the
lifetime of their scope, or whether you need dynamically created objects.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com