On Sat, 08 Jan 2005 23:34:53 +0200, Ioannis Vranos
<ivr@remove.this.grad.com> wrote:
[color=blue]
>Why this does not compile:
>
>
>class Sealed
>{
> friend class Fred;
> Sealed() { }
>};
>
>class Fred: virtual Sealed
>{};
>
>class Fred2: public Fred {};
>
>
>
>int main()
>{
> Fred2 a;
>}
>
>
>
>
>while this compiles?:
>
>
>class Sealed
>{
> friend class Fred;
> Sealed() { }
>};
>
>class Fred: Sealed
>{};
>
>class Fred2: public Fred {};
>
>
>
>int main()
>{
> Fred2 a;
>}[/color]
I believe that with a virtual base class, its constructor must be
accessible to the most derived class; whereas with non-virtual base
classes, this is not the case.
However -- although I have a hard-copy of the C++ standard -- I was
NOT able to find the text to support this. I merely recall having seen
something on either this NG, or comp.std.c++, or the moderated version
of this NG which would support this assumption.
Apparently, assuming that my assumption stated above is true, the
friend declaration doesn't have an effect here. All I can say is that
I tried to compile the examples given here with the Comeau compiler,
and I got the same results as you did.
--
Bob Hairgrove
NoSpamPlease@Home.com