Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!bellcore!faline!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: Calling constructors explicitly Message-ID: <8957@alice.UUCP> Date: 24 Feb 89 04:23:28 GMT References: <8102@paris.ics.uci.edu> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 26 In article <8102@paris.ics.uci.edu>, schmidt@siam.ics.uci.edu (Doug Schmidt) writes: > Apparently, cfront 2.0 also exhibits the same behavior. Would someone > please tell me whether this is a bug or a feature, i.e., is it part of > the language definition that constructors must not be called > explicitly? It's a feature. When I define a constructor, I should be entitled to assume that the constructor is initializing newly allocated storage -- that is, that there are no prior values in the object being constructed that I might have to preserve. That entitlement vanishes if it is possible to construct a given object more than once. Notwithstanding the above, there are arcane circumstances in which one may want to call a constructor explicitly. Should one ever be allowed to do so, it would be in circumstances where the caller would be expected to take responsibility for doing it only in the case where the object is not already constructed. C++ is not a completely safe language. -- --Andrew Koenig ark@europa.att.com