home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!wupost!m.cs.uiuc.edu!sunb10.cs.uiuc.edu!sparc6.cs.uiuc.edu!pjl
- From: pjl@sparc6.cs.uiuc.edu (Paul Lucas)
- Subject: Re: Return value for the constructors.
- Message-ID: <1992Aug18.210426.19494@sunb10.cs.uiuc.edu>
- Sender: news@sunb10.cs.uiuc.edu
- Organization: University of Illinois at Urbana-Champaign
- References: <3462@unisql.UUCP>
- Distribution: usa
- Date: Tue, 18 Aug 1992 21:04:26 GMT
- Lines: 20
-
- 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.
-
- Anyway, where would the return value _go_?
-
- class Foo {
- int Foo( ... ) { ... return expr; } // hypothetical
- };
-
- Foo x(...); // no use for a return-value here
- Foo *p = new Foo(...); // nor here; the address is returned
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-