From 4906812681467355614
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,edd477ec92e5348f
X-Google-Attributes: gidf78e5,public
X-Google-Thread: fc772,ef0c226459c03bdf
X-Google-Attributes: gidfc772,public
From: "Scott Meyers" <smeyers@aristeia.com>
Subject: Re: Protected Inheritance
Date: 1999/02/05
Message-ID: <5sGu2.19890$202.9738189@news1.teleport.com>#1/1
X-Deja-AN: 441228500
Approved: harkness@skeptics.org
Sender: cppmods@netlab.cs.rpi.edu
References: <Pine.GSO.3.95-960729.990131142619.5694B-100000@finan.ncl.ac.uk>' <slrn7bbi9a.q1a.sbnaran@localhost.localdomain> <sUPt2.16333$202.8056314@news1.teleport.com> <79aesq$qlr$1@uuneo.neosoft.com> <HEbu2.18017$202.8772558@news1.teleport.com> <slrn7bjmm5.q36.sbnaran@localhost.localdomain>
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Approved-For-Group: Fergus Henderson <fjh@cs.mu.oz.au> comp.std.c++
X-Original-Date: 05 Feb 99 19:32:18 GMT
Organization: -
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated iQBVAwUANruxakHMCo9UcraBAQG7ewH+MDaGJeSBmxx9Wn+nyvD1T7DMA3g8jOeh egsa4ylQDn2JJE36jrqKcdweH8vRmGR1QVAVPdvijQth7wMtNYjgig== =wryZ
Newsgroups: comp.lang.c++.moderated,comp.std.c++

Siemel Naran <sbnaran@localhost.localdomain.COM> wrote in message news:slrn7bjmm5.q36.sbnaran@localhost.localdomain...
>On 04 Feb 99 17:00:40 GMT, Scott Meyers <smeyers@aristeia.com> wrote:
>
>>  2 Names in a mem-initializer-id are looked up in the scope of the
>>    constructor's class and, if not found in that scope, are looked
>>    up in the scope containing the constructor's definition.
>
>>Does 12.6.2 really mean that private virtual base classes may be
>>initialized only by their immediate descendant classes (excluding
>>friendship issues)?
>
>I think that MSVC is indeed right in compiling your code:
>  class Base { public: explicit Base(int); };
>  class Sub1 : virtual private Base { public: Sub1(); };
>  class Sub2 : virtual private Base { public: Sub2(); };
>  class Derived : public Sub1, public Sub2 { public:
>     Derived() : Base(1), Sub1(), Sub2() { }
>  };
>  int main() { Derived(); }
>The compilers como and egcs also compile this.
>  
>This is because the Derived class really owns the Base subobject.

Where do you find support for this notion of "owernership" in the standard?

>The above class Derived is entirely equivalent to this
>  class Derived : virtual private Base, public Sub1, public Sub2 { public:
>     Derived() : Base(1), Sub1(), Sub2() { }
>  };

Maybe.  Compilers that lay out objects in the manner described in the ARM
would put an extra ptr-to-vbase in this latter definition of Derived, I believe.
At any rate, I'd still like to see support in the standard for your 
interpretation.  

FWIW, I *hope* it's true that indirect derived classes
can initialize private virtual bases, but I still think 12.6.2 can be
read to the contrary.

Scott

Scott Meyers, Ph.D.                  Voice: 503/638-6028
Author:  Effective C++ CD            Fax:   503/638-6614
         Effective C++               Email: smeyers@aristeia.com
         More Effective C++          WWW:   http://www.aristeia.com/
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




