🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #522

Re: Constructors/Destructors returning value?

#522
From: Ron Guilmette
Date: Fri, 21 Sep 1990 04:12
25 lines
1353 bytes
In article <Sep.17.11.06.04.1990.7553@elbereth.rutgers.edu> rgonzal@elbereth.rutgers.edu (Ralph Gonzalez) writes:
<
<Often I want to dynamically allocate space in my constructor.  If
<there's not enough memory to do so, it would be nice if the 'new'
<operator simply deleted the object for me and returned NULL.  Anything
<I was able to allocate in the constructor should in this case be
<deallocated by the constructor before it ends.  An alternative would
<be for 'new' to call the destructor before deleting the
<un-initializable object.
<
<This implies the constructor should return a boolean value, which is
<made use of by 'new'.
<
<What do you think?

I think this looks like a job for... ta ta da... exceptions!

(applause)

:-) :-)
-- 

// Ron Guilmette  -  C++ Entomologist
// Internet: rfg@ncd.com      uucp: ...uunet!lupine!rfg
// Motto:  If it sticks, force it.  If it breaks, it needed replacing anyway.
Technical Details
Message-ID: <1679@lupine.NCD.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!lupine!rfg
References: <Sep.17.11.06.04.1990.7553@elbereth.rutgers.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!lupine!rfg
From: rfg@NCD.COM (Ron Guilmette)
Newsgroups: comp.std.c++
Subject: Re: Constructors/Destructors returning value?
Message-ID: <1679@lupine.NCD.COM>
Date: 21 Sep 90 04:12:10 GMT
References: <Sep.17.11.06.04.1990.7553@elbereth.rutgers.edu>
Distribution: usa
Organization: Network Computing Devices, Inc., Mt. View, CA
Lines: 25