title: EXC_BAD_ACCESS when using vector iterators?
body: <p>I have a vector of vectors (a matrix) of a user-defined type, <code>my_type</code>, which is a struct and contains integers a, b, and c. I wish to define a function that finds an element of this matrix by the value of b and delete the element. Since the function doesn't know the value of c, I defined an iterator <code>it</code> to first find this element, and then set its pointer address to iterator <code>it_found</code> so that it can be used in erase() method. However, the program produced an error, <code>Program received signal EXC_BAD_ACCESS, Could not access memory,</code> when <code>it_found</code> is used. What is causing this error? </p>
  
  <pre><code>bool remove_V(int a, int b) {
      typename std::vector&lt;my_type&gt;::iterator it;  
      typename std::vector&lt;my_type&gt;::iterator it_found;  
  
  
          for(it = V.at(a).begin(); it != V.at(a).end(); ++it){
              if ((*it).b ==  1) {
                  it_found == it;
                  std::cerr &lt;&lt; (*it).b &lt;&lt; "\n";
                  std::cerr &lt;&lt; (*it_found).b &lt;&lt; "\n";
                  }
          }
  }
  </code></pre>