title: Copy elements from vector based on condition C++
body: <p>I'm using C++ to create Hopcroft's algorithm for DFA Minimization.</p>
  
  <p>Part of Hopcroft's algorithm is to - initially - divide two sets (P with accept and non-accept states and Q with non-accept states only). I already have group P, and from P I'm trying to extract Q. I'm using the following code to do it:</p>
  
  <pre><code>for(int i=0; i&lt;groupP.size(); i++)
      if(groupP[i]-&gt;final)
          groupQ.push_back(groupP[i]);
  </code></pre>
  
  <p>in which groupP and groupQ are:</p>
  
  <pre><code>vector&lt;node*&gt; groupQ;
  vector&lt;node*&gt; groupP;
  </code></pre>
  
  <p>and node is a structure that I've created to represent a node of my automata. It's guaranteed that the boolean attribute "final" is already correctly set (false for non-final states, true for final states).</p>
  
  <p>Finally, my question is: is it correct to copy one element from a vector to another by doing what I've done? If I modify the content of a copied element from groupP, will this same element be modified in groupQ as well?</p>