This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Member class access to private members of enclosing class

>This was recently changed; nested classes now do have access to their
>enclosing classes.  You can find the issue somewhere under


I am sorry to bother you, but I could not find where that page states
that nested class should have access to the enclosing class?  My
understanding of the C++ standard is that nested classes absolutely DO
NOT have access to the enclosing class protected and private members.  In fact there is a contradiction implied in the page you referenced if
that is indeed the case.  Item number 77 on that page:

77. The definition of friend does not allow nested classes to be friends 

That item states that the standard should be amended to allow inner
(nested) classes to become friends of the enclosing class.  If the inner
class already had access to the non-public members, there would be no
need to allow one to grant friendship to inner classes and the proposed
change would be uneeded.  I am guessing that the fact that g++ allows
inner classes to access the non-public members of the enclosing class
is a bug (of course a minor one) in g++.  Please let me know what item
on the above referenced page indicated to you that inner classes should
be allowed access to the non-public members of the outer class without
a declaration of friendship.  I did search that page for both the
words "friend" and "nested" and could not find any such information.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]