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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!math.fu-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: Thu, 20 Aug 1992 07:18:53 GMT
  8. Message-ID: <9985KTQ@netmbx.netmbx.de>
  9. References: <3462@unisql.UUCP> <1992Aug18.210426.19494@sunb10.cs.uiuc.edu> <H575V1E@netmbx.netmbx.de> <1992Aug19.163545.25066@sunb10.cs.uiuc.edu>
  10. Lines: 24
  11.  
  12. pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
  13.  
  14. >In <H575V1E@netmbx.netmbx.de> jrobie@netmbx.netmbx.de (Jonathan Robie) writes:
  15.  
  16.  
  17. >>    complex* p = new complex(i++);
  18. >>    if (p == 0)  // allocation failed!
  19.  
  20. >*****>    No; the allocator new() is returning zero, not the constructor.
  21. >    Also, if the ctor further allocates it's own stuff, there is 
  22. >    currently no clean way of returning that fact to the caller--
  23. >    new() will return success, i.e., non-zero.
  24.  
  25. >>On page 61 he also states that initialization will only be done if the
  26. >>return from the new is nonzero.
  27.  
  28. I was trying to say that you can at least check to see if the memory
  29. allocation succeeded.  
  30.  
  31. -- 
  32. Jonathan
  33.  
  34. ===========================================================================
  35.  
  36.