Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ulysses!hector!jss From: jss@hector.UUCP (Jerry Schwarz) Newsgroups: comp.lang.c++ Subject: Re: cfront 1.2.1 bug? Keywords: is it a bug, or is it me? is it fixed in 2.0? Message-ID: <11517@ulysses.homer.nj.att.com> Date: 11 May 89 13:52:32 GMT References: <9640@watcgl.waterloo.edu> Sender: netnews@ulysses.homer.nj.att.com Reply-To: jss@hector.UUCP (Jerry Schwarz) Distribution: comp Organization: AT&T Bell Laboratories Lines: 32 In article <9640@watcgl.waterloo.edu> al@watsup.waterloo.edu (Al Vermeulen) asks for help in understanding why some code fails to compile. I have simplified his example slightly struct A { A( A& ) ; }; void func2() { A a; // This declaration is rejected } C++ normally "synthesizes" two constructors for a class A. The one with no arguments and the one with an A& argument. When you declare any constructor C++ assumes that you want to specify all the constructors and therefore does not synthesize any. The declaration of a requires such a constructor with no arguments. To solve the problem you need to add a definition of the constructor with no arguments. struct A { A(A&) ; A() { } } ; Jerry Schwarz AT&T Bell Labs, Murray Hill