title: Mutual inclusion with inline function in C++
body: <p>I want to write some code like this: an <code>A</code> object calls its class <code>B</code> type member <code>b</code>'s member function <code>DoSomething</code>, and in class <code>B</code>'s <code>DoSomeOtherThing</code> member function, it calls <code>A</code>'s <code>Notify</code> member function. See the code below:</p>
  
  <p>Class A:</p>
  
  <pre><code>class A
  {
      B b;
  
  public:
      A() : b(*this)
      {
      }
  
      void DoSomething()
      {
          b.DoSomething();
      }
  
      void Notify()
      {
      }
  };
  </code></pre>
  
  <p>Class B:</p>
  
  <pre><code>class B
  {
      A &amp;a;
  
  public:
      B(A &amp;a) : a(a)
      {
      }
  
      void DoSomething()
      {
      }
  
      void DoSomeOtherThing()
      {
          a.Notify();
      }
  };
  </code></pre>
  
  <p>The problem is I want to keep the functions inline, so the code should be in header files. I can't simply include each other because they may cause mutual inclusion, and I don't know if a forward declaration can be use in this situation. I can write the implementation in source file but they will not be inline functions. So, how can I make the code work?</p>