*
:
>
> As for my post, I read something very clear about it in the FAQ so I
> will point to it.
> Item [24.6].
>
> To quote what is necessary:
> "None of the subclasses can access anything that is private in B [the
> base class]."
>
> Though I am still wondering. If you are using dynamic binding, which of
> the following two cases is legal?
>
> 1) Base b = new SubC(...);
> 2) SubC sc = new SubC(...);
>
> I would assume case 1. Am I right?
For (2), the object being declared is of type SubC, and the
initialization expression, using 'new', produces a SubC* pointer
(pointing to a dynamically allocated SubC object).
That will only work if SubC has a constructor that accepts a SubC pointer.
Presumably you meant to write
Base b* = new SubC(...); // 1
SubC sc* = new SubC(...); // 2
where both are valid if Base is, at this place in the code, an
/accessible/ base class of SubC.
It would be the same for
Base const& b = SubC( ... ); // 1
SubC const& sc = SubC( ... ); // 2
For example, if SubC is publicly derived from Base, then Base is always
an accessible base class.
There are two separate issues: implicit pointer (and reference) "upcast"
to a base class, and accessibility of said base class.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?