Re: Nested class doesn't obey member access rules

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Igor Tandetnik" wrote:
Here's quotation from 11.8/1 "Nested classes":

<quote>
The members of a nested class have no special access to members
of
an enclosing class

See DR45, whereby this paragraph is replaced with

"A nested class is a member and as such has the same access
rights as any other member."

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#45

Many compilers are tracking this DR. VC does since at least
VC7.1

Thanks for the prompt reply. It's good news. This fix makes much
more sense. Unfortunately, MSDN page is not updated even for most
recent compiler:

"Access Privileges and Nested Classes"
http://msdn2.microsoft.com/en-us/library/ee6hft63.aspx

Alex


.



Relevant Pages

  • Re: Nested class doesnt obey member access rules
    ... It should not be possible to access private members. ... Some compilers can give different results in such cases but if you do want same behaviour, use it as expected like above. ... The members of a nested class have no special access to members of an enclosing class, nor to classes or functions that have granted friendship to an enclosing class; the usual access rules shall be obeyed. ...
    (microsoft.public.vc.language)
  • Re: Overly friendly nested classes (was Confirm bad news)
    ... nested class within the same enclosing class. ... The language reference seems to confirm this, ... all members ... "Otherwise, if the member or constructor is declared private, then access ...
    (comp.lang.java.programmer)
  • Re: static classes, nested class, public class
    ... A 'regular' class my be used to create object instances for which the ... Such static members are accessed ... A nested class is a class that is defined inside another class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Confirm bad news
    ... nested class within the same enclosing class. ... class B {private int secret;} ... members have scope throughout the compilation ...
    (comp.lang.java.programmer)
  • Re: Nested class: accessing containing classs variables
    ... I'm sure you can just refer to the members by name. ... provide a reference to the enclosing class in order for the nested class to ...
    (microsoft.public.dotnet.languages.vb)