Type access control -- now too strict
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Sat Apr 1 00:00:00 GMT 2000
> > > Apparently it's now impossible to define static data of private type
> > > if that private type has a constructor.
> > > class B { B(int) {} };
> > [snip]
> > > A::B A::b(1);
> >
> > Particularly when the type's constructor is private :-)
>
> Ah, but that should work anyway, because A is an implicit friend of B.
It isn't. In standard C++, neither class is friend of the other.
According to Core Issue 45
# A member class should have access to the members of the enclosing
# class in the same manner as if it had been declared a friend of the
# enclosing class.
So B is implicit friend of A, but not vice versa.
Regards,
Martin
More information about the Libstdc++
mailing list