🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Constructors/Destructors returning value?

#515
From: Ralph Gonzalez
Date: Mon, 17 Sep 1990 15:06
19 lines
1138 bytes
Hi.  I'm not much of an expert on C++ (I mostly use Think C 4.0, a
similar but less detailed language), so perhaps the following
suggestion doesn't make sense stylistically, but here goes:

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?

-Ralph
Technical Details
Message-ID: <Sep.17.11.06.04.1990.7553@elbereth.rutgers.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!elbereth.rutgers.edu!rgonzal

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!elbereth.rutgers.edu!rgonzal
From: rgonzal@elbereth.rutgers.edu (Ralph Gonzalez)
Newsgroups: comp.std.c++
Subject: Constructors/Destructors returning value?
Message-ID: <Sep.17.11.06.04.1990.7553@elbereth.rutgers.edu>
Date: 17 Sep 90 15:06:06 GMT
Distribution: usa
Organization: Rutgers Univ., New Brunswick, N.J.
Lines: 19