title: How to refer to an "owner class" in C++?
body: <p>I have code that looks like this:</p>
  
  <pre><code>template&lt;class T&gt;
  class list
  {
  public:
      class iterator;
  };
  
  template&lt;class T&gt;
  class list::iterator
  {
  public:
      iterator();
  protected:
      list* lstptr;
  };
  
  list&lt;T&gt;::iterator::iterator()
  {
      //???
  }
  </code></pre>
  
  <p>I want to make the constructor of <code>list::iterator</code> to make <code>iterator::lstptr</code> point to the list it's called from.  I.e.:</p>
  
  <pre><code>list xlst;
  xlst::iterator xitr;
  //xitr.lstptr = xlst
  </code></pre>
  
  <p>How would I do that?</p>
  
  <p>And also, am I referencing my iterator-constructor right, or should I do something like this:</p>
  
  <pre><code>template&lt;class T&gt;
  class list&lt;T&gt;::iterator
  {
  public:
      list&lt;T&gt;::iterator();
  protected:
      list* lstptr;
  };
  </code></pre>