Path: 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: Date: 17 Sep 90 15:06:06 GMT Distribution: usa Organization: Rutgers Univ., New Brunswick, N.J. Lines: 19 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