title: Using the fstream getline() function inside a class
body: <p>I'm trying to load lines of a text file containing dictionary words into an array object. I want an array to hold all the words that start with "a", another one for "b" ... for all the letters in the alphabet.</p>
  
  <p>Here's the class I wrote for the array object.</p>
  
  <pre><code>    #include &lt;iostream&gt;
      #include &lt;string&gt;
      #include &lt;fstream&gt;
  
      using namespace std;
  
      class ArrayObj
      {
      private:
  
          string *list;
          int size; 
  
      public:
  
  
          ~ArrayObj(){ delete list;}
  
          void loadArray(string fileName, string letter)
          {
              ifstream myFile;
              string str = "";
              myFile.open(fileName);
  
              size = 0;
  
              while(!myFile.eof())
              {
                  myFile.getline(str, 100);
  
                  if (str.at(0) == letter.at(0))
                      size++;
              }
              size -= 1; 
  
              list = new string[size];
  
              int i = 0;
              while(!myFile.eof())
              {
                  myFile.getline(str, 100);
  
                  if(str.at(0) == letter.at(0))
                  {
                      list[i] = str;
                      i++;
                  }
              }
  
              myFile.close();
          }
  
  
      };
  </code></pre>
  
  <p>I'm getting an error saying:</p>
  
  <pre><code>2   IntelliSense: no instance of overloaded function     "std::basic_ifstream&lt;_Elem, _Traits&gt;::getline [with _Elem=char, _Traits=std::char_traits&lt;char&gt;]" matches the argument list d:\champlain\spring 2012\algorithms and data structures\weeks 8-10\map2\arrayobj.h  39
  </code></pre>
  
  <p>I guess it's requiring me to overload the getline function, but I'm not quite certain how to go about or why it's necessary. </p>
  
  <p>Any advice?</p>