home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!uwm.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!sunb10.cs.uiuc.edu!sparc10.cs.uiuc.edu!pjl
- From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
- Newsgroups: comp.lang.c++
- Subject: Re: Return value for the constructors.
- Message-ID: <1992Aug19.231926.28218@sunb10.cs.uiuc.edu>
- Date: 19 Aug 92 23:19:26 GMT
- Article-I.D.: sunb10.1992Aug19.231926.28218
- References: <3462@unisql.UUCP> <1992Aug18.210426.19494@sunb10.cs.uiuc.edu> <H575V1E@netmbx.netmbx.de> <1992Aug19.163545.25066@sunb10.cs.uiuc.edu> <1992Aug19.175852.38459@watson.ibm.com>
- Sender: news@sunb10.cs.uiuc.edu
- Distribution: usa
- Organization: University of Illinois at Urbana-Champaign
- Lines: 22
-
- In <1992Aug19.175852.38459@watson.ibm.com> mittle@watson.ibm.com (Josh Mittleman) writes:
-
- >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().
-
- *****> Clever...but it's not reentrant.
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-