title: Reading file into structure (c++)
body: <p>I am very very new to C++, and I would like to read a text file into a structure. The text file has a double on the first line, and the lines after that exist as gift names (wishes). I created a struct, Wishlist, that exist as a double and a vector of wishes. So I did the following: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  struct Gift
  {
      double price;
      string name;
  };
  
  typedef vector&lt;Gift&gt; Giftstore;
  typedef vector&lt;string&gt; Wishes;
  
  
  int size(Giftstore&amp; g) {return static_cast&lt;int&gt;(g.size());}
  
  int size(Wishes&amp; w) {return static_cast&lt;int&gt;(w.size());}
  
  
  struct Wishlist
  {
      double budget;
      Wishes wishes;
  };
  
  
  void reading_wishlist(ifstream&amp; file, Wishlist&amp; wish_list)
  {
      if (file)
      {
          double money;
  
          file&gt;&gt;money;
          wish_list.budget&lt;&lt;money;
      }
  
      while(file)
      {
          string name;
          getline(file, name)
          wish_list.wishes.push_back(name);
      }
  
      file.close();
  };
  
  
  void print(Wishlist wish_list)
  {
      cout&lt;&lt;"Budget: "&lt;&lt;wish_list.budget&lt;&lt;endl;
      cout&lt;&lt;"Wishes: "&lt;&lt;endl;
  
      for(int i=0; i&lt;size(wish_list.wishes()); i++)
      {
          cout&lt;&lt;wish_list.wishes[i]&lt;&lt;endl;
      }
  };
  
  int main () {
  
    ifstream file;
    string filename;
    cout&lt;&lt;"Give a wishlist file: ";
    cin&gt;&gt;filename;
  
    file.open(filename)
    reading_wishlist(filename, wish_list);
    print(wish_list)
  
    return 0;
  }
  </code></pre>
  
  <p>Of course, while trying to build and run this, I again won some error prizes! The first one, is saying: (in reference to: wish_list.budget&lt;
  
  <p>Invalid operands of types 'double' and 'double' to binary operator&lt;&lt;</p>
  
  <p>What does this mean? Do I have to redefine the operator &lt;&lt; ?  Or can I read the double as a Cstring and then change it to double? </p>
  
  <p>What is the best way to deal with this? Better: how to read different types from a file? Since I also have to read a file into a structure, Giftstore, where the text file will consist of a double and a gift name on each line.</p>