title: What is the reason to we can not define friend function in local class?
body: <p>I have a following snippet code of c++. Declared a class inside <code>main()</code> function.</p>
  
  <p>What is the reason to we can not define friend function in local class?</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  int main()
  {
      class Foo
      {
          void foo() {} // Ok
          friend void Bar(){}; // Error
      };
  }
  </code></pre>