Article View: comp.std.c++
Article #2118Re: object contruction/destruction in c++, design flaw?
From: Joe Buck
Date: Thu, 05 Oct 1995 08:31
Date: Thu, 05 Oct 1995 08:31
38 lines
1615 bytes
1615 bytes
fjh@munta.cs.mu.OZ.AU (Fergus Henderson) writes:
I've compressed Fergus's example (for writing a constructor that is
safe from out-of-memory exceptions) a bit by putting the constructor inline.
The result goes like this.
class a {
public:
auto_ptr<char> mBuffer1;
auto_ptr<char> mBuffer2;
a() {
mBuffer1 = new char[1000];
mBuffer2 = new char[1000];
}
};
Looks good; no destructor needed. But just a minute: auto_ptr<T>'s
destructor does
delete T;
not
delete [] T;
right? This means this usage is incorrect, even though it so happens
that it will work in many implementations for objects without destructors.
Shouldn't there be a separate auto_array_ptr to handle pointers to arrays
correctly?
--
-- Joe Buck <jbuck@synopsys.com> (not speaking for Synopsys, Inc)
Anagrams for "information superhighway": Enormous hairy pig with fan
A rough whimper of insanity
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<44ufeb$r9e@hermes.synopsys.com>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backReferences:
<henk_kampman-2909951146290001@huisie-ppp1.knoware.nl> <9527516.21208@mulga.cs.mu.oz.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 05 Oct 95 08:31:35 GMT Approved: fjh@cs.mu.oz.au From: jbuck@Synopsys.COM (Joe Buck) Newsgroups: comp.std.c++ Subject: Re: object contruction/destruction in c++, design flaw? X-Original-Date: 4 Oct 1995 17:14:51 GMT Organization: Synopsys Inc., Mountain View, CA 94043-4033 Message-ID: <44ufeb$r9e@hermes.synopsys.com> References: <henk_kampman-2909951146290001@huisie-ppp1.knoware.nl> <9527516.21208@mulga.cs.mu.oz.au>