title: C++: Passing reference of constructing object to constructed member objects?
body: <p>Okay, consider the following classes:</p>
  
  <pre><code>class Object
  {
  public:
      // Constructor
      Object() : 
          [Initialization List]
      {
          ...
      }
      ...
  };
  
  class Container
  {
  public:
      Object A;
      Object B;
  
      ....
  
      Container() :
          [Initialization List]
      {
      }
  };
  </code></pre>
  
  <p>I'd like to provide [access to Container and it's members] to the Objects.</p>
  
  <p>My first thought was to somehow pass a reference to the current Container object to the constructors of the Objects.  But I can't figure out how to do this.</p>
  
  <p>I've messed around with "this", but I'm not getting anything that works.  I tried something like this:</p>
  
  <pre><code>class Object
  {
  public:
      Container&amp; c
  
      // Constructor
      Object(Container&amp; c_) : 
          c(c_)
      {
          ...
      }
      ...
  };
  
  class Container
  {
  public:
      Object A;
      Object B;
  
      ....
  
      Container() :
          A(Object(this))
          B(Object(this))
      {
      }
  };
  </code></pre>
  
  <p>My eventual goal is to be able to access Object B from inside a member method of Object A.</p>
  
  <p>Does anyone have any insight on how to get closer to what I'm looking for?</p>
  
  <p>Thanks!</p>