title: Basic use of classes to perform basic quantitative biology
body: <p>I'm writing a program that performs basic quantitative biology operations.  I have two separate files, a .h and .cpp.  The .h contains my class with function prototypes and my .cpp contains my function definitions.  I feel like I wrote the code correctly but it won't compile.  Here is my code:</p>
  
  <pre><code>//.h file
  
  #ifndef __JMCREADY_QUBIENGINE_H_
  #define __JMCREADY_QUBIENGINE_H_
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  class QubiEngine{
  private:
     vector&lt;string&gt; dna;
  public:
     QubiEngine();                    //Default constructor
     QubiEngine(ifstream&amp; dnaFile);       //Reads lines from given input file and pushes every read DNA sequence into the dna vector.
     void dna2rna();              //Reads the DNA from the dna vector and computes it's RNA, then stores them in a file rna.txt
     void compute_revcom();           //Reads the DNA sequences from the dna vector, computes the reverse, and stores in revcom.txt
     void nucl_frequency();           //Counts the total occurances of each nucleotide in the DNA sequence.
     int count_CpG();             //Counts the occurance of the string "CG"
     bool isPalindromic();                //Checks if the string is palindromic.
  
  };
  
  #endif
  //.cpp file
  
  #include "jmcready_QubiEngine.h"
    #include &lt;iostream&gt;
    #include &lt;string&gt;
    #include &lt;vector&gt;
    #include &lt;fstream&gt;
    #include &lt;algorithm&gt;
    #include &lt;iterator&gt;
    using namespace std;
  
    QubiEngine::QubiEngine(ifstream&amp; dnaFile){
      string neucleotides;                    //Declares an empty string of nucelotides,
                                          //opens the file to be stored into the vector,
      while (getline(dnaFile, neucleotides)){ //and while it is reading the whole line from the
         dna.push_back(neucleotides);     //dnaFile, it is pushing the nucelotides into the vector.
     }
    }
  
  
   void QubiEngine::dna2rna(){
     ofstream outfile;
     outfile.open("rna.txt");         //Creates a blank text file
     const char* foo = "t";
     for (vector&lt;string&gt;::iterator it = dna.begin(), endOfString = dna.end(); it != endOfString; it++){
      if ( find(dna.begin(), dna.end(), foo) != dna.end() ){              //for loop with a nested if statement to run through each
          dna.at(*foo) = "u";                  //member of the vector and check if the iterator is equal
          outfile &lt;&lt; *it;             //to "t", if it is, it is changed to "u."
      }                               //Then saves the new iterator value to the outfile.
  }
   outfile.close();               //Closes the file so no further changes can be made.
  }
  
  void QubiEngine::compute_revcom(){
  char letter = '\0';
  
  ofstream outfile;
  outfile.open ("revcom.txt");            //Another blank text file.
  vector&lt;string&gt; temp;                //A dummy blank vector to store the reverse of the dna vector.
  reverse( dna.begin(), dna.end() );  //Stores the reverse of vector dna to temp vector.
                 for (vector&lt;string&gt;::iterator it = temp.begin(), endOfString = temp.end(); it != endOfString; it++){
                     while ( it != dna.end() ){       //For loop with nested while loop to change
                         switch(letter){              //each element in the temp vector to it's complement element.
                             case 'a' :
                                 *it = "t";
                                 break;
                             case 't' :
                                 *it = "a";
                                 break;
                             case 'c' :
                                 *it = "g";
                                 break;
                             case 'g' :
                                 *it = "c";
                                 break;
                             default :
                                 cout &lt;&lt; "File contains elements that aren't valid, please fix."&lt;&lt; endl;
                                 break;
                         }
                     }
    }
    outfile.close();
  }
  
   void QubiEngine::nucl_frequency(){
  int numOfA = 0;             //Declares multiple counts and letters
      int numOfT = 0;             //to keep track of each nucleotide seperately
      int numOfC = 0;
      int numOfG = 0;
      string a = "a";
      string t = "t";
      string c = "c";
      string g = "g";
  
      for (vector&lt;string&gt;::iterator it = dna.begin(), endOfString = dna.end(); it != endOfString; it++){
          if (*it == a){              //For loop with multiple nested if statements
                  numOfA++;                   //to check each individual element
              }                       //and count it towards the total.
              if(*it == t){
                      numOfT++;
              }
              if (*it == c){
                      numOfC++;
              }
              if (*it == g){
                      numOfG++;
              }
      }
   }
  
  int QubiEngine::count_CpG(){
  
  int count = 0;
      string CpG = "cg";
  
      for (vector&lt;string&gt;::iterator it = dna.begin(), endOfString = dna.end(); it != endOfString; it++){
          if (*it == CpG){                //For loop with nested if statement to check
                  count++;                    //for the string "cg" and add them to an int
              }                       //counter.
      }
  
      return count;
  }
  
  
  bool QubiEngine::isPalindromic(){
  
  for (vector&lt;string&gt;::iterator it = dna.begin(), endOfString = dna.end(); it != endOfString; it++){
  
      if(*it == string(dna.rbegin(), dna.rend())){        //For loop with nested if statement
                  return true;
              }                                //to check if *it is equal to
              else{
                      return false;
              }                            //the reverse of it's original,
                                                      //if it is equal than it is palindromic.
                     }
  }
  
  
  
  int main (int args, char* argv[]) {         //Main function given in the pdf, calls each
  
  ifstream dnaFile;                   //public function to check if it works, and how
      dnaFile.open("dna.txt");
  
      QubiEngine qbengine(dnaFile);               //effectively.
      qbengine.dna2rna();
  
      qbengine.compute_revcom();
  
      qbengine.nucl_frequency();
  
      int cpg = qbengine.count_CpG();
      cout &lt;&lt; "The total number of CG islands is : " &lt;&lt; cpg &lt;&lt; endl;
  
      if ( qbengine.isPalindromic() )
          cout &lt;&lt; "Palindromic" &lt;&lt; endl;
      else
          cout &lt;&lt; "Not Palindromic" &lt;&lt; endl;
      return 0;
  };               
  </code></pre>
  
  <p>EDIT: I've managed to fix as many mistakes as I can. The only thing left are a few compiler errors, was hoping if someone can give me some tips.  The errors are in the comments at the bottom</p>