title: C++ - Creating a god object
body: <p>Hypothetical situation that I'm struggling to get my head past.</p>
  
  <pre><code>HoldsFooBar.h:
  #include "foo.h"
  #include "bar.h"
  class HoldsFooBar{
      foo F;
      bar B;
  };
  
  
  foo.h:
  //includes?
  class foo{
      HoldsFooBar *H;
      void Baz();
  };
  
  
  bar.h:
  //includes?
  class bar{
      HoldsFooBar *H;
      void Qux();
  };
  </code></pre>
  
  <p>I'm trying to get F to get a hold of B. In all other languages I've worked with, I would be able to <code>H-&gt;B.Qux();</code>, but I'm totally lost in C++. At the includes lines in <code>foo.h</code> and <code>bar.h</code>, it seems like my options are to forward-declare <code>class HoldsFooBar;</code> but then I can only access H, and F and B cannot see each other. Likewise, I can <code>#include "HoldsFooBar.h"</code> but because of my include guards, something ends up not getting linked properly, so the program doesn't run.</p>
  
  <p>Is what I'm trying to do even possible? Thank you very much! Any help would be appreciated!</p>