Why does this code compile?
<p>What are the exact rules for deciding the access rights for the objects nested into the private sections of other objects? </p>

<p>For example, in the code snipped below, the <code>proxy_t</code> struct is nested into the private section of the <code>abc_t</code>, and yet its methods are available to the <code>main</code> function. Why does it compile at all?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;valarray&gt;

using namespace std;

class abc_t{
  private: 
    struct proxy_t{
      proxy_t operator()(double&amp; a, double&amp; b){ __a=a; __b=b; return *this; }
      double a(){ return __a; }
      double b(){ return __b; }
      private:
        double __a, __b;
    };

  public:
    abc_t( const size_t N ){ 
       _a.resize(N,-101.); 
       _b.resize(N,-202.);  
    }
    double a(size_t j){ return _a[j]; }
    double b(size_t j){ return _b[j]; }

    proxy_t operator[](const size_t j) { return _proxy(_a[j],_b[j]); }

  private:
    valarray&lt;double&gt; _a;
    valarray&lt;double&gt; _b;
    proxy_t _proxy;
};


int main(){
 size_t n_elem=10;
 abc_t abc(n_elem);
 cout&lt;&lt;"direct: "&lt;&lt; abc.a(1)&lt;&lt;"  "&lt;&lt;abc.b(1)&lt;&lt;"\n";
 cout&lt;&lt;"proxied:"&lt;&lt;abc[1].a()&lt;&lt;"  "&lt;&lt;abc[1].b()&lt;&lt;"\n";  // ain't proxy_t::aa() private?
 //cout&lt;&lt;abc[1]; // doomed to fail
}
</code></pre>
