title: Reading a input file into a vector
body: <p>I'm trying to read a file of <code>int</code>'s and <code>double</code>'s into a vector but I am having difficulty doing so. Given something like:</p>
  
  <pre><code>1 2.1 3 4
  2 4 
  3
  9 0.1
  </code></pre>
  
  <p>How can I use <code>ifstream</code> and the <code>getline</code> function to convert the string into integers and doubles &amp; inserting this into a vector?</p>
  
  <p>I know this is incorrect but I am thinking of something along the lines of:</p>
  
  <pre><code>vector&lt;Pair *&gt; vec; //Pair is a class that contains a int &amp; a double data member
  string str;
  double num;
  ifstream f;
  f.open("name of file");
  while(getline(f, str){
    num = stod(str);
  }
  </code></pre>
  
  <p>To insert into the vector I believe I can do something along the lines of:</p>
  
  <pre><code>Pair * pairObj = new Pair(x,y); //"x" being of type int and "y" being of type double
  v.push_back(pair);
  </code></pre>
  
  <p>I'm sorry if this is unclear, please let me know and I will do my best to explain myself.</p>