From 8904277453069659026
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: "Larry Brasfield" <clcppm-poster@this.is.invalid>
Subject: Re: Protected Inheritance
Date: 1999/02/07
Message-ID: <hZ7v2.2348$GN.1054@news.rdc1.wa.home.com>#1/1
X-Deja-AN: 441590748
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
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> <7sAoNOBfshu2EwFV@robinton.demon.co.uk>
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Original-Date: 7 Feb 1999 00:34:18 -0500
X-Complaints-To: news@news.unimelb.edu.au
X-Approved-For-Group: daveed@vandevoorde.com comp.lang.c++.moderated
X-Trace: izvestia.its.unimelb.edu.au 918372180 29842 128.250.29.16 (7 Feb 1999 07:23:00 GMT)
Organization: Serendipitous Endeavors
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANr0/NeEDnX0m9pzZAQEA3QF/cHxYhHhP1WA9AOVpDqIfDxDpX6d7ZsGi kRaC2mM+tdCY76ILSDgLG1sWs+ApuAWn =nbA+
X-WARNING-TO-MODERATORS: This article has been processed and accepted using a cryptographic program by the moderator of comp.lang.c++.moderated. Its content must not be changed or it will be automatically cancelled. If you don't like the article or its crossposting, return it to the submitter.  (You can delete this message if you are the last moderator to see it.)
NNTP-Posting-Date: 7 Feb 1999 07:23:00 GMT
Newsgroups: comp.std.c++,comp.lang.c++.moderated

I am answering Scott's question and addressing an issue
raised by Francis.  (It's post conservation in action.)

Francis Glassborow wrote in message <7sAoNOBfshu2EwFV@robinton.demon.co.uk>...
>In article <HEbu2.18017$202.8772558@news1.teleport.com>, Scott Meyers
><smeyers@aristeia.com> writes
>>Does 12.6.2 really mean that private virtual base classes may be
>>initialized only by their immediate descendant classes (excluding
>>friendship issues)?

Paragraph 6 of 12.6.2 says "All sub-objects representing
virtual base classes are initialized by the constructor of the
most derived class" and "A mem-initializer naming a virtual
base class shall be ignored during execution of the constructor
of any class that is not the most derived class."  (This relates
to the earlier stated requirement that the most derived class
constructor initilizes virtual bases before anything else.)  What
this means is that it doesn't matter whether intermediate base
classes do the initialization or not; the most derived constructor
is supposed to take over that responsibility.

>I always understood that making a virtual base private was a waste of
>time because:
>
>class A {};
>
>class B: private virtual A {};
>
>class C: public virtual A, public B {};
>
>now provides access to the private virtual base.  Maybe my memory is at
>fault.

I think calling that inheritance structure "a waste of
time" is to lose sight of what is being controlled by
making derivation private.  It is not so much to guard
the base against outside corruption as to restrict the
interface exposed by the derived class.  The above
private (virtual) inheritance does that for class B.  The
fact that class C (or its designer, more accurately) has
chosen to expose its A base is C's (designer's) affair,
of no concern to the design of B.  Presumably, what
utility A had for B survives sharing (which is implicit
in virtual inheritance) by classes that derive from B.
That utility is independent of whether those classes
elect to expose A as part of their interface.

--Larry Brasfield
Above opinions may be mine alone.
(Humans may reply at unundered larry_br@sea_net.com )



