title: Friend for nested structure in C++
body: <p>I know <a href="http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html" rel="nofollow">Thinking in C++</a> by Bruce Eckel is not a reference book but I found a strange paragraph and I don't understand if it's still applicable today:</p>
  
  <blockquote>
    <p>Making a structure nested doesn’t automatically give it access to
    private members. To accomplish this, you must follow a particular
    form: first, declare (without defining) the nested structure, then
    declare it as a friend, and finally define the structure. The
    structure definition must be separate from the friend declaration,
    otherwise it would be seen by the compiler as a non-member.</p>
  </blockquote>
  
  <p>I actually tried this without declaring the nested structure as a friend and it worked:</p>
  
  <pre><code>struct myStruct{
  private:
      int bar;
  public:
      struct nestedStruct{
          void foo(myStruct *);
      }a;
  };
  
  void myStruct::nestedStruct::foo(myStruct * p){
      p-&gt;bar = 20;
  }
  </code></pre>
  
  <p>Is there still a need to declare a nested structure friend in order to modify the private members of the base class?</p>