home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12539 < prev    next >
Encoding:
Text File  |  1992-08-18  |  1.4 KB  |  49 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!math.fu-berlin.de!zrz.tu-berlin.de!news.netmbx.de!netmbx!jrobie
  3. From: jrobie@netmbx.netmbx.de (Jonathan Robie)
  4. Subject: Re: Return value for the constructors.
  5. Organization: netmbx, Berlin, Germany
  6. Distribution: usa
  7. Date: Wed, 19 Aug 1992 06:52:12 GMT
  8. Message-ID: <H575V1E@netmbx.netmbx.de>
  9. References: <3462@unisql.UUCP> <1992Aug18.210426.19494@sunb10.cs.uiuc.edu>
  10. Lines: 37
  11.  
  12. pjl@sparc6.cs.uiuc.edu (Paul Lucas) writes:
  13.  
  14. >In <3462@unisql.UUCP> nandraj@unisql.UUCP (Nandraj Arni) writes:
  15.  
  16. >>   Why does C++ not let you have a return value for a constructor?
  17. >>Is there any rationale behind this?
  18.  
  19. >*****>    Because there's nothing for it to return.  A c'tor is s'posed to
  20. >    turn raw memory into an object.  Period.
  21.  
  22. But note this example from the ARM, page 62:
  23.  
  24.     complex* p = new complex(i++);
  25.     if (p == 0)  // allocation failed!
  26.  
  27. On page 61 he also states that initialization will only be done if the
  28. return from the new is nonzero.
  29.  
  30. So I think that it is safe to check the pointer to see if it is zero.
  31.  
  32.  
  33. Jonathan
  34.  
  35. ===========================================================================
  36.  
  37. Jonathan Robie        jrobie@netmbx.UUCP
  38. Arnold-Zweig-Str. 44    jrobie@netmbx.in-berlin.de
  39. O-1100 Berlin        
  40. Deutschland        Phone:  +37 (2) 472 04 19  (Home, East Berlin)
  41.                 +49 (30) 342 30 66 (Work, West Berlin)
  42.  
  43.  
  44. -- 
  45. Jonathan
  46.  
  47. ===========================================================================
  48.  
  49.