home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!math.fu-berlin.de!zrz.tu-berlin.de!news.netmbx.de!netmbx!jrobie
- From: jrobie@netmbx.netmbx.de (Jonathan Robie)
- Subject: Re: Return value for the constructors.
- Organization: netmbx, Berlin, Germany
- Distribution: usa
- Date: Wed, 19 Aug 1992 06:52:12 GMT
- Message-ID: <H575V1E@netmbx.netmbx.de>
- References: <3462@unisql.UUCP> <1992Aug18.210426.19494@sunb10.cs.uiuc.edu>
- Lines: 37
-
- pjl@sparc6.cs.uiuc.edu (Paul Lucas) writes:
-
- >In <3462@unisql.UUCP> nandraj@unisql.UUCP (Nandraj Arni) writes:
-
- >> Why does C++ not let you have a return value for a constructor?
- >>Is there any rationale behind this?
-
- >*****> Because there's nothing for it to return. A c'tor is s'posed to
- > turn raw memory into an object. Period.
-
- But note this example from the ARM, page 62:
-
- complex* p = new complex(i++);
- if (p == 0) // allocation failed!
-
- On page 61 he also states that initialization will only be done if the
- return from the new is nonzero.
-
- So I think that it is safe to check the pointer to see if it is zero.
-
-
- Jonathan
-
- ===========================================================================
-
- Jonathan Robie jrobie@netmbx.UUCP
- Arnold-Zweig-Str. 44 jrobie@netmbx.in-berlin.de
- O-1100 Berlin
- Deutschland Phone: +37 (2) 472 04 19 (Home, East Berlin)
- +49 (30) 342 30 66 (Work, West Berlin)
-
-
- --
- Jonathan
-
- ===========================================================================
-
-