From 3296905696593016486
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8a4cd038fc33ea5a
X-Google-Attributes: gidf78e5,public
From: clamage@Eng.Sun.COM (Steve Clamage)
Subject: Re: Ambiguous conversion due to private ba
Date: 1998/03/25
Message-ID: <6f9nbr$sg5@engnews1.Eng.Sun.COM>#1/1
X-Deja-AN: 337686738
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <3517FB6C.6DE8@central.beasys.com>
X-Original-Date: 25 Mar 1998 01:41:15 GMT
Organization: Sun Microsystems Inc.
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANRmLDOEDnX0m9pzZAQFBvwF/d5HIfS8cJu1C+Hg3MZDqstNyjxh/nZ1H dQLIftKgggQc5gUbRCj95oVvKlwv6SPf =b6ZW
Reply-To: clamage@Eng.Sun.COM
Newsgroups: comp.std.c++


In article 6DE8@central.beasys.com, David R Tribble <david.tribble@central.beasys.com> writes:
>jkanze@otelo.ibmmail.com wrote:
>> ...
>> But doesn't this sort of
>> defeat the purpose of private inheritance?  Private inheritance isn't
>> meant to represent an isA relationship.
>
>Huh?  Inheritance does mean an IsA relationship, private or
>otherwise.  Or does C++ grant some special meaning to private
>inheritance that doesn't apply to inheritance in general?

The IsA relationship means that you can use a Derived any place a
Base was expected. When you use private inheritance, that property
doesn't hold. In addition, private inheritance means the base class
interface is not usefully part of the derived class interface.
Example:
	class Base { public: void f(); ... };
	class Derived : private Base { ... };

	void foo(Base&);
	Base b;
	...
	Derived d;
	foo(d); // error, no implicit conversion to Base&
	b = d;  // error, cannot assign Derived to Base
	d.f();  // error, f is not accessible

Thus, private inheritance fails any test of the IsA relationship.

---
Steve Clamage, stephen.clamage@sun.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              ]



