🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3392

Re: virtual base class initialization

#3392
From: Steve Clamage
Date: Wed, 21 Feb 1996 21:03
34 lines
1820 bytes
In article IAA16749@ncar.ucar.EDU, weber@ezibk8.vmsmail.ethz.ch writes:
> 
>// I am not sure how to interprate the ARM (or the Draft C++ Standard) 
>// with regard to the initialization of a virtual base class.
>
 ... V is a virtual base class of A

>class C2: public A, public B{
>public:
>    C2(int i): A(i){}
>};
>
>// C2 is not directly derived from V. In this case I don't think the base
>// class should still be initialized by the most derived class.

Yes it should. The most-derived class initializes all the virtual base
classes in its hierarchy, whether the virtual base classes are direct
base classes or not. None of the intermediate base classes initialize
any of the virtual base classes.

It would be possible to define other (probably more complicated) rules
to specify a different order of initialization, but that is the C++ rule.  

---
Steve Clamage, stephen.clamage@eng.sun.com



[ To submit articles: Try just posting with your newsreader.
		      If that fails, use mailto:std-c++@ncar.ucar.edu
  FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID: <4gfs4g$ju2@engnews1.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <199602211555.IAA16749@ncar.ucar.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: clamage@Eng.sun.com (Steve Clamage)
Newsgroups: comp.std.c++
Subject: Re: virtual base class initialization
Date: 21 Feb 1996 21:03:09 GMT
Organization: Sun Microsystems Inc.
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <4gfs4g$ju2@engnews1.Eng.Sun.COM>
References: <199602211555.IAA16749@ncar.ucar.EDU>
Reply-To: clamage@Eng.sun.com
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: taumet.eng.sun.com
Content-Length: 902
X-Lines: 27
Originator: clamage@taumet