title: C++ Outer class access Inner class's private - why forbidden
body: <p>Hello I am wondering why C++ standard allows us in nested classes to access outer class's private fields, while it forbids to access inner class's private fields from the outer class. I understand, that this example:</p>
  
  <pre><code>class OuterClass{
  public:
      class InnerClass{
      public:
          void printOuterClass(OuterClass&amp; outer) {cout &lt;&lt; outer.m_dataToDisplay;};
      };
  private:
      int m_dataToDisplay;
  };
  </code></pre>
  
  <p>is fine, because thing, that Inner class sometimes can be complicated. But I think following scenario is also fine:</p>
  
  <pre><code>class Algorithm{
  public:
      class AlgorithmResults{
      public:
          void readAlgorithmResult();
      private:
          void writeAlgorithmResult();
      };
  
      void calculate(AlgorithmResults&amp; results, Arguments...){
         //calculate stuff
         results.writeAlgorithmResult(results);
      }
  };
  </code></pre>
  
  <p>For me this structure makes perfect sense, although it is not allowed in C++. I also noticed, that for some time both were allowed in Java, but now second example is also forbidden.
  What is the reason, that first example is allowed and another is denied?</p>