title: How to change value of item in stl list?
body: <p>I have a question about changing or replacing elements in a list. I have a class:</p>
  
  <pre><code>class Node{ 
  public:
     elType type; // enum
     string name;
  
      Node(elType type, string name);
     ~Node();
  
      void printNodeInfo();
  }
  </code></pre>
  
  <p>and a list:</p>
  
  <pre><code>    std::list &lt;Node * &gt; someList;
  </code></pre>
  
  <p>Now how can i replace a value (for eaxmple change type) in such element.
  I've tried this:</p>
  
  <pre><code>        std::list&lt;Node * &gt;::iterator it = someList.end();
          it--;
  
          while(openName.compare((*it)-&gt;name) != 0)
              it--;
  
          (*it)-&gt;type = otherType;
  </code></pre>
  
  <p>But it does not seem to work, the type stays the same. I'd be grateful for any help.</p>
  
  <hr>
  
  <p>EDIT:
  I updated the list so now I have:</p>
  
  <pre><code>std::list &lt;Node&gt; someList;
  </code></pre>
  
  <p>and changed the replacing to:</p>
  
  <pre><code>it-&gt;type = otherType;
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>std::list&lt;Node &gt;::iterator it2 = someList.erase(it);
  Node temp(otherType, openName);
  someList.insert(it2, temp);
  </code></pre>
  
  <p>after this for both cases a simple method for printing :</p>
  
  <pre><code>it2-&gt;printNodeInfo();
  </code></pre>
  
  <p>outputs nothing.</p>