Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!batcomputer!lijewski From: lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) Newsgroups: comp.std.c++ Subject: Re: Nit of the day. Message-ID: <1990Dec16.200441.581@batcomputer.tn.cornell.edu> Date: 16 Dec 90 20:04:41 GMT References: <3000@lupine.NCD.COM> Organization: Cornell National Supercomputer Facility Lines: 36 In article <3000@lupine.NCD.COM> rfg@lupine.ncd.com (Ron Guilmette) writes: >I'm at it again. Picking nits as usual. > >Given: > > struct S { > int i; > }; > > void S (void); > > void foobar () > { > S (); > } > >Did I call the explicitly declared function `S' or did I call the >implicitly compiler-created constructor for `struct S'? Good question. On page 27 of E&S is an example very similar to yours. The answer in that case is the function `S' would be called. If we then turn to page 167 there is an example of a class X with an explicit constructor w/ prototype X(int);. If we also have a function void X(int); the statement X(1); becomes ambiguous. Seems to me we need a much better explanation of when an implicitely-defined default constructor is generated and, a bit more explicitely, can I call such a constructor in a program. I would also like to know why a default constructor is generated for EVERY class which has no explicitely- declared constructors (page 264 E&S). Seems to me this contradicts the example on page 27. -- Mike Lijewski (H)607/272-0238 (W)607/254-8686 Cornell National Supercomputer Facility ARPA: lijewski@theory.tn.cornell.edu BITNET: mjlx@cornellf.bitnet SMAIL: 25 Renwick Heights Road, Ithaca, NY 14850