title: C++, reading a file using ifstream
body: <pre><code>class Person {
  private:
      string firstName;
      string lastName;
  public:
      Person() {}
  
      Person(ifstream &amp;fin) {
         fin &gt;&gt; firstName &gt;&gt; lastName;
      }
  
      void print() {
         cout &lt;&lt; firstName
             &lt;&lt; " "
             &lt;&lt; lastName
             &lt;&lt; endl;
      }
  };
  
  int main() {
      vector&lt;Person&gt; v;
      ifstream fin("people.txt");
  
      while (true) {
          Person p(fin);
          if (fin == NULL) { break; }
          v.push_back(p);
      }
  
      for (size_t i = 0; i &lt; v.size(); i++) {
         v[i].print();
      }
  
      fin.close();
      return 0;
  }
  </code></pre>
  
  <p>Please can you explain me, how following code snippet works?
  if (fin == NULL) { break; }</p>
  
  <p>fin is a object on stack, not a pointer so it can not become NULL.
  I was unable to find overloaded operator== function in ifstream class.
  So I can not understand how this snippet works.</p>