title: class object is not reading from text file using fsream
body: <p>Hi I am having an issue with fstream variable. my movie class can't read info from the a text file: </p>
  
  <p>here is the output is produces: </p>
  
  <pre><code>-858993460 Ì -858993460 -858993460 -9.25596e+061 -858993460 -858993460
  -858993460 Ì -858993460 -858993460 -9.25596e+061 -858993460 -858993460
  -858993460 Ì -858993460 -858993460 -9.25596e+061 -858993460 -858993460
  -858993460 Ì -858993460 -858993460 -9.25596e+061 -858993460 -858993460
  -858993460 Ì -858993460 -858993460 -9.25596e+061 -858993460 -858993460
  -858993460 Ì -858993460 -858993460 -9.25596e+061 -858993460 -858993460
  -858993460 Ì -858993460 -858993460 -9.25596e+061 -858993460 -858993460
  -858993460 Ì -858993460 -858993460 -9.25596e+061 -858993460 -858993460
  </code></pre>
  
  <p>and it SHOULD produce:</p>
  
  <pre><code> 110 8.3 2005 275523 A 140 Batman begins
   123 8.2 1965 45515 W 132 For a Few Dollars More
   181 8.1 1946 17648 R 172 The Best Years of Our Lives
   30 8.6 1946 103101 D 130 it's a Wonderful Life
   77 8.3 1952 56368 C 103 Singin' in the Rain
   88 8.3 1995 245089 A 177 Braveheart
   45 8.5 2001 185124 C 122 Amelie
   48 8.5 1962 80746 V 216 Lawrence of Arabia
  </code></pre>
  
  <p>and input text is: </p>
  
  <pre><code> 110 8.3 2005 275523 A 140 Batman begins
   123 8.2 1965 45515 W 132 For a Few Dollars More
   181 8.1 1946 17648 R 172 The Best Years of Our Lives
   30 8.6 1946 103101 D 130 it's a Wonderful Life
   77 8.3 1952 56368 C 103 Singin' in the Rain
   88 8.3 1995 245089 A 177 Braveheart
   45 8.5 2001 185124 C 122 Amelie
   48 8.5 1962 80746 V 216 Lawrence of Arabia
   -1
  </code></pre>
  
  <p>At this point I am having a hard time understanding why it's doing that. I am using MS VS2008.</p>
  
  <p>here is the code:</p>
  
  <pre><code>#include "movieType.h"
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  int main()
  {
  movieType movie[9];
  ifstream inFile("movie1.txt");
  
  int i =0;
  
  bool notDone=true;
  while (notDone) 
  { 
      if (movie[i++].readMovieInfo(inFile)== false)
          notDone=false;    
  }
  
  for (int i=0;i&lt;8;++i)
  {
      movie[i].printMovieInfo("printList.txt");
  }
  
  return 0;
  }
  </code></pre>
  
  <p>and the class specification</p>
  
  <pre><code>#include &lt;string&gt;
  //include preprocessor directive to give access to string operations
  
  class movieType
  {
  public:
      movieType();
      //Function: Class constructor
      //Precondition: none
      //Postcondition: instance variable initialized
  
      ~movieType();
      //Function: class destructor
      //Precondition: object has been initialized
      //Postcondition: memory allocated to class object freed up
  
      bool readMovieInfo(std::ifstream&amp;);
      //Function: reads one movie at one time from a file
      //Precondition: object has been initialized
      //Postcondition: return false if the rank is &lt;1 else return true
  
      void printMovieInfo(char*);
      //Function:prints one movie at a time to a file
      //Precondition: object has been initialized
      //Postcondition: none
  
      char getGenre();
      //Function: returns the movie genre
      //Precondition:object has been initialized
      //Postcondition: none
  
      int getRank();
      //Function: returns the movie rank
      //Precondition: object has been initialized
      //Postcondition: none
  
      bool operator&gt;=(movieType) const;
      //Function: overload operator for '&lt;=' for use in heap
      //Precondition: object has been initialized
      //Postcondition:none
  
      bool operator&gt;(movieType) const;
      //Function: overload operator for '&lt;' for use in heap
      //Precondition: object has been initialized
      //Postcondition:none
  
  private:
      int rank; //movie ranking
      double weight; //calculated wieght for ranking
      int year; //year the movie was released
      int votes; //number of votes 
      char genre; //movie genre
      int length; //movie length in minute
      std::string name; //the name of the movie
  
  };
  </code></pre>
  
  <p>and the class implementation:</p>
  
  <pre><code>#include "movieType.h"
  //preprocessor directive gives access to movieType class
  #include &lt;fstream&gt;
  //preprocessor directive gives access fstream operations
  #include &lt;string&gt;
  //preprocessor directive gives access string operations
  
  using namespace std;
  // make fstream and string operations available without calling class std
  
  
  movieType::movieType()
  {
  }
  
  movieType::~movieType()
  {
  }
  
  bool movieType::readMovieInfo(ifstream&amp; inFile)
  {
      inFile&gt;&gt;rank&gt;&gt;weight&gt;&gt;year&gt;&gt;votes&gt;&gt;genre&gt;&gt;length;
      getline(inFile,name);
  
      if (rank &lt; 1)
          return false;
      else
          return true;
  }
  
  void movieType::printMovieInfo(char* outFileName)
  {
  std::ofstream outFile;
  if(!outFile.is_open()) 
      outFile.open(outFileName, std::ios::app);
  outFile&lt;&lt;name&lt;&lt;" "&lt;&lt;year&lt;&lt;" "&lt;&lt;genre&lt;&lt;" "&lt;&lt;length&lt;&lt;" "&lt;&lt;rank;
  outFile&lt;&lt;" "&lt;&lt;weight&lt;&lt;" "&lt;&lt;year&lt;&lt;" "&lt;&lt;votes&lt;&lt;std::endl;
  
  }
  int movieType::getRank()
  {
  return rank;
  }
  
  char movieType::getGenre()
  {
  return genre;
  }
  
  bool movieType::operator &gt;=(movieType other) const
  {
  if (rank &gt;= other.rank)
      return true;
  else
      return false;
  }
  
  bool movieType::operator &gt;(movieType other) const
  {
  if (rank &gt; other.rank)
      return true;
  else
      return false;
  } 
  </code></pre>