From -3471637397059526779
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8a4cd038fc33ea5a
X-Google-Attributes: gidf78e5,public
From: Marc Girod <girod@stybba.ntc.nokia.com>
Subject: Re: Ambiguous conversion due to private ba
Date: 1998/04/01
Message-ID: <1y90ppoj1p.fsf@dshp01.ntc.nokia.com>#1/1
X-Deja-AN: 339849669
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <35202460.4826@usa.net> <6fr9km$bou@engnews1.Eng.Sun.COM>
X-Original-Date: 01 Apr 1998 14:52:50 +0300
X-Emacs: Emacs 20.2, MULE 3.0 (MOMIJINOGA)
Mime-Version: 1.0 (generated by SEMI MIME-Edit 0.98 - =?ISO-8859-4?Q?"D=F2?= =?ISO-8859-4?Q?h=F2ji"?=)
Content-Type: text/plain; charset=US-ASCII
Organization: Nokia Telecommunications OY
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANSJWb+EDnX0m9pzZAQESzQF/Ya4pdv+CcmuDrcu77M7jaccDOB2mLwOy +qpL9G4xdETokLXLTLLEQLz7qmS3FaGL =kDHv
Newsgroups: comp.std.c++


>>>>> "SC" == Steve Clamage <clamage@Eng.Sun.COM> writes:

SC> In article 4826@usa.net, Srinivas Vobilisetti <srinivas-v@usa.net> writes:
>> Herb Sutter wrote:
>>> 
>>> Valentin Bonnard <bonnardv@pratique.fr> wrote:
>>> >Steve Clamage wrote:
>>> >> Thus, private inheritance fails any test of the IsA relationship.
>>> >
>>> >I would say that private inheritance is a private IsA relationship.
>>> >It means that only some trusted functions (member, friends) are
>>> >aware of the relationship, which may change in the future.
>>> 
[...]
SC> That's correct, but the access applies only to immediate base classes.

You meant "to immediate derived classes", but you dropped friends.

SC> class B { };

SC> void f(B*);
SC> class D : private B {
    friend class E;
SC> public:
SC>         void g() { f(this); } // OK, convert D* to B*
SC> };

    class E {
    public:
            void h(D* d) { f(d); } // OK
    protected:
            B* base(D* d) { return d; } // OK
    };

SC> The "polymorphism" you do get is restricted to one level, so I don't
SC> think it is useful to describe this situation as polymorphism or "IsA"
SC> at all. If Valentin wants to invent a term "private IsA" to describe
SC> this special case, I suppose he can do so, but I think that is more
SC> misleading than helpful.

The polymorphism is scoped, that's all.
With the second member of E, it is even as deep as you want (in one
sense).

This is "interface dedication", extremely common and useful,
especially when applied to friend classes. Think at it as a
generalization of iterators to statefull accessors.

-- 
Marc Girod                Valimo 1/2         Voice:  +358-9-511 63331
Nokia Telecommunications  P.O. Box 315       Mobile: +358-40-569 7954
NWS/NMS/NMS for Data      00045 NOKIA Group  Fax:    +358-9-511 63310
                          Finland            marc.girod@ntc.nokia.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              ]



