Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!rutgers!mcnc!thorin!zeta!tuck From: tuck@zeta.cs.unc.edu (Russ Tuck) Newsgroups: comp.lang.c++ Subject: Re: virt base c'tor -- my error or CC bug? Keywords: CC, cfront, 2.0, multiple inheritance, virtual base class Message-ID: <11624@thorin.cs.unc.edu> Date: 24 Jan 90 02:37:01 GMT References: <11582@thorin.cs.unc.edu> <48359bd1.20b6d@apollo.HP.COM> Sender: news@thorin.cs.unc.edu Reply-To: tuck@zeta.cs.unc.edu (Russ Tuck) Distribution: na Organization: University Of North Carolina, Chapel Hill Lines: 38 In article <48359bd1.20b6d@apollo.HP.COM> vinoski@zep.UUCP (Stephen Vinoski) writes: >In article <11582@thorin.cs.unc.edu> tuck@jason.cs.unc.edu (Russ Tuck) writes: >>On p. 82, section 12.6.2, of the C++ (2.0) Reference Manual (AT&T select >>code 307-146), it says: >> >>"All sub-objects for virtual base classes are initialized by the constructor >>of the most derived class. If a constructor of the most derived class >>does not specify a mem-initializer for a virtual base class then that >>virtual base class must have a default constructor or no constructors." > >From Lippman's "C++ Primer", Addison-Wesley, ISBN 0-201-16487-6, page 363: > >"A base class specified as virtual must, if it defines any constructors, define >a constructor that does not require an argument list - either a constructor >taking no arguments or one in which default value is provided for each >argument." Thanks for pointing out a clear contradiction between these two authoritative references. I thought the Reference Manual (by Stroustrup) was the ultimate authority, but here Lippman is in better agreement with the compiler. (Which is "right" is another question. Would the authors care to say?) In contrast, GNU's C++ compiler, g++, corresponds to the Reference Manual, rather than to Lippman and cfront. >P.S. IMHO Lippman's "C++ Primer" is the best C++ book going. If you don't have >it you should get a copy. I have it. I hadn't consulted it in this case, because what I found in the Reference Manual spoke so directly to the issue. But when I looked at p. 363, I found your quote above already marked with faded highlighter. (The book hasn't been in print for a year yet, so my marker must be cheap and my memory less than perfect.) Russ Tuck tuck@cs.unc.edu UNC Dept. of Computer Science ...!mcnc!unc!tuck CB 3175, Sitterson Hall Chapel Hill, NC 27599-3175, USA (919) 962-1755 or 962-1700