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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!wupost!m.cs.uiuc.edu!sunb10.cs.uiuc.edu!sparc6.cs.uiuc.edu!pjl
  3. From: pjl@sparc6.cs.uiuc.edu (Paul Lucas)
  4. Subject: Re: Return value for the constructors.
  5. Message-ID: <1992Aug18.210426.19494@sunb10.cs.uiuc.edu>
  6. Sender: news@sunb10.cs.uiuc.edu
  7. Organization: University of Illinois at Urbana-Champaign
  8. References: <3462@unisql.UUCP>
  9. Distribution: usa
  10. Date: Tue, 18 Aug 1992 21:04:26 GMT
  11. Lines: 20
  12.  
  13. In <3462@unisql.UUCP> nandraj@unisql.UUCP (Nandraj Arni) writes:
  14.  
  15. >   Why does C++ not let you have a return value for a constructor?
  16. >Is there any rationale behind this?
  17.  
  18. *****>    Because there's nothing for it to return.  A c'tor is s'posed to
  19.     turn raw memory into an object.  Period.
  20.  
  21.     Anyway, where would the return value _go_?
  22.  
  23.     class Foo {
  24.         int Foo( ... ) { ... return expr; }    // hypothetical
  25.     };
  26.  
  27.     Foo x(...);            // no use for a return-value here
  28.     Foo *p = new Foo(...);        // nor here; the address is returned
  29. -- 
  30.     - Paul J. Lucas                University of Illinois    
  31.       AT&T Bell Laboratories        at Urbana-Champaign
  32.       Naperville, IL            pjl@cs.uiuc.edu
  33.