incomplete type error , when using friend functions
<pre><code>#include &lt;stdio.h&gt;
class B;

class A;

class A
{

    int a;
    friend int B::f();

};


class B
{

    int b;
    class A x;
 public:
    int f();

};

int B::f()
{
   ...

}

main()
{

 class B b;

 b.f();

}
</code></pre>

<p>ERRORS:</p>

<pre><code>a.cpp:9: error: invalid use of incomplete type ‘struct B’

a.cpp:2: error: forward declaration of ‘struct B’
</code></pre>

<p>The issue cannot be solved by placing defn of B before A as
A has an object of type B</p>

<p>For this example making B a friend class would do, but in 
my real code I have more member functions in B (so I need alternative solution).</p>

<p>Finally, can somebody give me links that explain what the compiler does when it comes
across a forward declaration, declaration, definition. </p>
