title: Reading from a file (ifstream) and sorting
body: <p>I need to read from a file and then break the line into 3 strings.
  The format is: 
  A first_<strong>The Secod</strong>_Third (three underscores)
  It's homework, and they suggest us using getline and ignore.
  so I have:</p>
  
  <pre><code>    main()
      ifstream inf("file.txt")
      while(inf)
      {inf &gt;&gt; class1;
      cout &lt;&lt; class1;
      }
      class THECLASS
      {string a, b, c;
      public:
      friend void operator&gt;&gt;(ifstream &amp;inf, THECLASS &amp;class1)
      {getline(inf, class1.a, '_');
      inf.ignore();
      inf.ignore();
      [if I put getline class1.b, the whole line will go into it, overwriting .a]
      }
  
  and in operator&lt;&lt;, I have
  
      os &lt;&lt; class1.a &lt;&lt; class1.b;
      return os;
  </code></pre>
  
  <p>But all I get when I cout &lt;&lt; class1 are all three fields of input file without <em>_</em>, each on a new line. 
  When I tried using get() function, compiler won't recognize it even though I declared fstream.
  What is the general algorithm of doing it? </p>