Nested classes: Access to protected member of enclosing class from a nested protected class
<p>This code compiles on msvc/g++:</p>

<pre><code>class A{
protected:
    int i;
    class B{
    public:
        A* a;
        B(A* a_)
        :a(a_){
        }
        void doSomething(){
            if (a)
                a-&gt;i = 0;//&lt;---- this part
        }       
    };
public:
    A()
    :i(0){
    }
};
</code></pre>

<p>As you can see, B gets access to "protected" section of enclosing class, although it isn't declared as friend. </p>

<p>Is this a standard(standard-conforming) behavior? </p>

<p>I use this feature sometimes, but I don't remember a rule saying that nested protected class should automatically get access to all protected data of enclosing class.</p>
