title: Forward declaration with friend function: invalid use of incomplete type
body: <pre><code>#include &lt;iostream&gt;
  
  class B;
  
  class A{
   int a;
  public:
   friend void B::frndA();
  };
  
  class B{
   int b;
  public:
   void frndA();
  };
  
  void B::frndA(){
   A obj;
   std::cout &lt;&lt; "A.a = " &lt;&lt; obj.a &lt;&lt; std::endl;
  }
  
  int main() {
   return 0;
  }
  </code></pre>
  
  <p>When trying to compile this code, some errors occurred. E.g.</p>
  
  <blockquote>
    <p>invalid use of incomplete type</p>
  </blockquote>
  
  <p>What are the problems in this code?</p>