home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!swrinde!zaphod.mps.ohio-state.edu!malgudi.oar.net!news.ans.net!newsgate.watson.ibm.com!yktnews!admin!!mittle
- From: mittle@watson.ibm.com (Josh Mittleman)
- Newsgroups: comp.lang.c++
- Subject: Re: Return value for the constructors.
- Message-ID: <1992Aug19.175852.38459@watson.ibm.com>
- Date: 19 Aug 92 17:58:52 GMT
- References: <3462@unisql.UUCP> <1992Aug18.210426.19494@sunb10.cs.uiuc.edu> <H575V1E@netmbx.netmbx.de> <1992Aug19.163545.25066@sunb10.cs.uiuc.edu>
- Sender: news@watson.ibm.com (NNTP News Poster)
- Distribution: usa
- Organization: IBM T.J. Watson Research Center
- Lines: 18
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- Nntp-Posting-Host: siena.watson.ibm.com
-
- pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
-
- *****> No; the allocator new() is returning zero, not the constructor.
- > Also, if the ctor further allocates it's own stuff, there is
- > currently no clean way of returning that fact to the caller--
- > new() will return success, i.e., non-zero.
-
- Sure there is: Overload operator new(). For example, give your class a
- static status flag. operator new() sets it to 1, then calls ::new() to
- allocate the object. Your constructors make whatever internal checks they
- need, and set status to 0 if there is a problem. Then, operator new()
- returns a pointer to the new object or 0, depending on the success of the
- process. From the users point-of-view, it simply looks like a normal call
- to new().
-
- ===========================================================================
- Josh Mittleman (mittle@watson.ibm.com)
- J2-C28 T.J. Watson Research Center, PO Box 704, Yorktown Heights, NY 10598
-