In article <WtQ1b.7710$QT5.2690@fed1read02>,
cheeser_1998@yahoo.com
says...[color=blue]
> Hello all,
>
> The example below demonstrates proper conformance to the C++ standard.
> However, I'm having a hard time getting my brain around which language rules
> make this proper...
>
> The error below *should* happen, but my question to the community is *why*
> does it happen?[/color]
Because you've asked for it to happen. Private inheritance means
exactly that: the relationship between the derived and the base class is
not visible to the outside world, so the conversion from derived to base
that's allowed with public inheritance isn't allowed with private
inheritance.
[color=blue]
> P.S. I do understand the conceptual difference between public / private
> inheritance (i.e. "is-a" vs. "has-a").[/color]
A "has-a" relationship is normally expressed by aggregation -- i.e. one
object containing an instance of another. The usual description for
private inheritance is "is implemented in terms of". E.g. a stack being
implemented in terms of a vector -- a stack doesn't support the full
interface of a vector, so we can't use public inheritance. At the same
time, it would be wasteful to use aggregation, because all the data
needed for a stack is already contained in a vector.
This is fairly typical: private inheritance is often used when the base
object includes _more_ functionality than needed, and the private
inheritance is used to create a more limited interface (directly
contrary to public inheritance, which means the derived object must
support at least the full base interface, and may add more).
--
Later,
Jerry.
The universe is a figment of its own imagination.