title: Dynamically inserting into a set
body: <p>I would like to know how to insert data into a set dynamically.
  I have a text file with different points and i need to insert into the set dynamically as i will not know how many items will be there.</p>
  
  <p>sample.txt</p>
  
  <pre><code>Point [3 4]
  Point [5 6]
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code> set&lt;Point&gt; s_p2;
   if (strData.find("Point") != string::npos) {
     pos = strData.find("t");
     strData = strData.substr(pos + 2, 4);
     istringstream in(strData);
     Point temp_p;
     in &gt;&gt; temp_p;
     s_p2.insert(temp_p);
  }
  </code></pre>
  
  <p><code>s_p2</code> is the set container and the following set of codes are looped till the end of the file.</p>
  
  <p>Q1: If I do this, will my set have only 1 item or multiple items of <code>temp_p</code>?</p>
  
  <p>Q2: How can i print out the values in side the set?</p>
  
  <p>.</p>
  
  <pre><code>ostream&amp; operator&lt;&lt;(ostream &amp;out, Point &amp;p2) {
      p2.setDistFrOrigin();
      out &lt;&lt; "[" &lt;&lt; setw(4) &lt;&lt; p2.getX() &lt;&lt; setw(1) &lt;&lt; "," &lt;&lt; setw(4) &lt;&lt; p2.getY() &lt;&lt; "]   " &lt;&lt; setprecision(3) &lt;&lt; p2.getScalarValue() &lt;&lt; endl;
  }
  </code></pre>