title: list iterator as way to access and modify std:list content
body: <p>Say you have list </p>
  
  <p><strong>NTlist</strong> (abstractly represented here): </p>
  
  <pre><code>     ["string2", RHSlist ]&lt;--&gt;["string1", RHSlist ]&lt;--&gt;["string3", RHSlist ]
  </code></pre>
  
  <p>Now, you search for the element of <code>NTlist</code> containing "string1" using a list iterator, <strong>NTlocation</strong>.  As a result of search, <code>NTlocation</code> then "points" to the middle element.  </p>
  
  <p>The goal is to add to this middle element's RHSlist.  I do that with: </p>
  
  <pre><code> NTlocation-&gt;RHSlist.push_back(RHSentry); //where RHSentry is of type RHSnode. 
  </code></pre>
  
  <p><strong>The question</strong>:<br>
  Why is the middle element's RHSlist not updated? Rather, it is the iterator NTlocation that has it's own RHSlist that is updated.</p>
  
  <p>Thanks for your time.</p>
  
  <pre><code>#include &lt;list&gt;
  #include &lt;iostream&gt;
  #include &lt;string.h&gt;
  using namespace std;
  
  typedef struct RHSnode {
  string token;
  } RHSnode;
  
  typedef struct NTnode {
  string token;
  list&lt;RHSnode&gt; RHSlist;
  } NTnode;
  
  list&lt;NTnode&gt;::iterator searchNTList(string NTstring, list&lt;NTnode&gt; &amp;NTlist);
  
  int main(int argc, const char * argv[]) {
   list&lt;NTnode&gt; NTlist;
   list&lt;NTnode&gt;::iterator NTlocation;
  
  // making three entries in NTList
  NTnode entry1;
  entry1.token = "string2";
  NTlist.push_back(entry1);
  
  NTnode entry2;
  entry2.token = "string1";
  NTlist.push_back(entry2);
  
  NTnode entry3;
  entry3.token = "string3";
  NTlist.push_back(entry3);
  
  RHSnode RHSentry;
  RHSentry.token = "RHSentry";
  
  //Now, say, I want to put this RHSentry (above) into NTlist with
  // element that has it's token as "string1"
  // so I search NTlist for token with "string1"
  // and remember the NTlist element location with iterator NTlocation
   NTlocation = searchNTList("string1", NTlist);
  
  // Now here's where the problem occurs
   NTlocation-&gt;RHSlist.push_back(RHSentry);
  
  return 0;
  }
  
  list&lt;NTnode&gt;::iterator searchNTList(string NTstring, list&lt;NTnode&gt; &amp;NTlist){
  //"past-the-end" indications search failure
  list&lt;NTnode&gt;::iterator NTlocation = NTlist.end();
  
  list&lt;NTnode&gt;::iterator iterator = NTlist.begin();
  
  for ( ; iterator != NTlist.end() ; iterator++ ){
  
      if (iterator-&gt;token.compare(NTstring) == 0){
          NTlocation = iterator;
          break;
      }
  
  }
   return NTlocation;
  }
  </code></pre>