title: C++ Reading From a .txt File + Binary Search + Sorting; Trouble with Classes
body: <p>So I need to read 10,000 numbers from an input.txt file, and then search to see if it is in the array, and if it isn't there, insert it and increment the frequency value in the frequency array. Then I need to sort the arrays in decreasing order by the frequency array. I know I am missing alot still... but my main question is found in main.cpp. When I reference TermTable.BinarySearch and TermTable.Sort, I get "Error: expected an identifier". Here is my main.cpp file. SO my biggest question is: Why can't I access the methods in the class TermTable??</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include "TermTable.h"
  
  using namespace std;
  
  int main(){
  const int size = 10000;
  int termArray[size];
  int frequencyArray[size];
  char * charArray = new char[size];
  int position = 0;
  ifstream fin("input.txt");
  if (fin.is_open())
  {
      cout &lt;&lt; "Open" &lt;&lt; endl;
      while (!fin.eof() &amp;&amp; position &lt; size){
          fin.get(charArray[position]);
          position++;
      }
      charArray[position - 1] = '\0';
      for (int i = 0; charArray[i] != '\0'; i++)
      {
          termArray[i] = charArray[i];
      }
      for (int i = 0; termArray[i] != '\0'; i++){
          int searchValue = termArray[i];
          TermTable.BinarySearch(int termArray, int size, int searchValue);
          if (position != -1){ frequencyArray[i] += 1; }
          else if (position == -1){ 
              frequencyArray[i] = 0;
          }
  
      }
      TermTable.Sort(int termArray, int size);
  }
  else 
  {
      cout &lt;&lt; "couldn't open" &lt;&lt; endl;
  }
  return 0;
  }
  </code></pre>
  
  <p>And Here's my specification .cpp file.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include "TermTable.h"
  using namespace std;
  
  
  int TermTable::BinarySearch(int array[], int size, int searchValue){
  int first, last, middle, position; bool found; first = 0; last = size - 1; found = false; position = -1;
  while (!found &amp;&amp; first &lt;=last)
  {
      middle = (first + last) / 2; 
      if (array[middle] == searchValue)
      {
          found = true;
          position = middle;
      }
      else if (array[middle] &gt; searchValue)
          last = middle - 1;
      else
          first = middle + 1;
  }
  return position;
  }
  
  void TermTable::Sort(int array[], int size){
  int temp; bool swapOccurred;
  do{
      swapOccurred = false;
      for (int count = (size-1); count &gt; 0; count--)
      {
          if (array[count] &lt; array[count - 1])
          {
              temp = array[count];
              array[count] = array[count - 1];
              array[count - 1] = temp;
              swapOccurred = true;
          }
      }
  } while (swapOccurred);
  }
  </code></pre>
  
  <p>And here is my class file.</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  //class specification
  class TermTable {
  
  public:
  //constructor
  TermTable();
  
  //member functions
  int BinarySearch(int array[],int size, int searchValue);
  void Insert(int value);
  void Sort(int array[],int size);
  
  //destructor
  ~TermTable();
  
  private:
  //data
  int currentAmount;
  
  };
  </code></pre>