title: need help on operator << overloading functions
body: <p>The error I'm getting right now is:</p>
  
  <blockquote>
    <p>multiple definition of <code>operator&lt;&lt;(std::ostream&amp;, SingleSequence&amp; s)</code></p>
  </blockquote>
  
  <p>the error location is at one of the overload operator function:</p>
  
  <pre><code>std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const SingleSequence&amp; s)
  {
      os &lt;&lt; s.name &lt;&lt; " " &lt;&lt; s.seq &lt;&lt; " " &lt;&lt; s.length &lt;&lt; " " &lt;&lt; s.gccontent &lt;&lt; " " &lt;&lt; s.type;
      return os;
  }
  </code></pre>
  
  <p>This is the driver part:</p>
  
  <pre><code> #include"Sequences.h"
   #include &lt;iostream&gt;
   #include &lt;fstream&gt;
   #include &lt;cmath&gt;
   #include &lt;ctime&gt;
   #include &lt;cstdlib&gt;
  
   using namespace std;
  
   int main(){
  
   cout &lt;&lt; "Assignment #1" &lt;&lt; endl;
  
  Sequences mysequences;
  cout &lt;&lt; mysequences;
  cout &lt;&lt; "Sorted by name" &lt;&lt; endl;
  mysequences.sortByName();
  cout &lt;&lt; mysequences;
  cout &lt;&lt; "Sorted by length" &lt;&lt; endl;
  mysequences.sortByLength();
  cout &lt;&lt; mysequences;
  cout &lt;&lt; "... done!" &lt;&lt; endl;
   }
  </code></pre>
  
  <hr>
  
  <p>This is the Sequences.h</p>
  
  <pre><code>#ifndef SEQUENCES_H_
  #define SEQUENCES_H_
  #include&lt;string.h&gt;
  #include&lt;strings.h&gt;
  #include&lt;string&gt;
  #include&lt;iostream&gt;
  using namespace std;
  
  
  enum sequenceType { dna, rna, protein };
   struct SingleSequence{
      std::string name;
      std::string seq;
      int length;
      double gccontent;
      sequenceType type;
  
  
  };
  
  class Sequences {
  
  public:
  
  
  Sequences();
  virtual ~Sequences();
  int getListSize() const{return datasize;}
   const SingleSequence&amp; get( int i) const{
      if (i&gt;=0 &amp;&amp; i &lt; datasize)
                  return data[i];
              throw OUT_OF_BOUNDS;;//{ if (i&gt;=0 &amp;&amp; i &lt; datasize)
   }
  //        return data[i];
  //    throw OUT_OF_BOUNDS;} // C++ has exceptions - you can even throw ints;
  void sortByName();
  void sortByLength();
  friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const SingleSequence&amp; s)  ;
  friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const Sequences&amp; seqs) ;
  int datasize;
  
  private:
  /*
   * Remember to keep all data members private
   */
  static const int MAX_LIST_SIZE = 20;
  SingleSequence data[MAX_LIST_SIZE];
  
  static const int OUT_OF_BOUNDS = -1;
  
  
  };
  
  std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const SingleSequence&amp; s)
   { os &lt;&lt; s.name &lt;&lt; " " &lt;&lt; s.seq &lt;&lt; " " 
       &lt;&lt; s.length &lt;&lt; " " &lt;&lt; s.gccontent &lt;&lt; " "&lt;&lt;s.type;  
    return os;
    }
  #endif /* SEQUENCES_H_ */
   -------------------------------------------------------------
  </code></pre>
  
  <p>This is the main cpp file</p>
  
  <pre><code>#include "Sequences.h"
  #include &lt;iostream&gt;
  using namespace std;
  Sequences::Sequences() {
  
      data[0] = { "KCNH2 Primer Pair 1 Forward", "CCAACTGGTGGACCGTCATT", 20, 55.0, dna };
      data[1] = { "KCNH2 Primer Pair 1 Reverse", "GACAGCCAGGTGAACATCCA", 20, 55.0, dna };
      data[2] = { "KCNH2 Primer Pair 2 Forward", "TGGATGTTCACCTGGCTGTC", 20, 55.0, dna };
      data[3] = { "KCNH2 Primer Pair 2 Reverse", "CCACGGAACCTCTGGCAATA", 20, 55.0, dna };
      data[4] = { "KCNH2 Primer Pair 3 Forward", "GAACGGAAGTGTGCCAACTG", 20, 55.0, dna };
      data[5] = { "KCNH2 Primer Pair 3 Reverse", "ACAGCCAGGTGAACATCCAG", 20, 55.0, dna };
      data[6] = { "KCNH2 Primer Pair 4 Forward", "CTGGATGTTCACCTGGCTGT", 20, 55.0, dna };
      data[7] = { "KCNH2 Primer Pair 4 Reverse", "ATTTCCACGGAACCTCTGGC", 20, 55.0, dna };
      data[8] = { "KCNH2 Primer Pair 5 Forward", "TGAAAACCGCTCGTCTGC", 18, 55.6, dna };
      data[9] = { "KCNH2 Primer Pair 5 Reverse", "GGTGGAGCATGTGTTGTT", 18, 50.0, dna };
  
      datasize = 10;
  
      }
  
  void Sequences::sortByName(){
  for(int i = 0; i &lt; 10; i++){
      //int flag = 1;
      SingleSequence temp;
       for(int j = 0; j &lt; 9; j++){
  
        if (data[j].name.compare(data[j+1].name) &gt; 0){
           temp = data[j+1];
           data[j+1] = data[j];
           data[j] = temp;
     }
          }
        }
     }
  
     void Sequences::sortByLength(){
       for(int a = 0; a &lt; 10; a++){
  
              SingleSequence temp1;
              for(int b = 0; b &lt; 9; b++){
                  if (data[b].length &gt; data[b+1].length){
                           temp1 = data[b+1];
                           data[b+1] = data[b];
                           data[b] = temp1;
              }
  
           }
          }
      }
  
    std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const Sequences&amp; seqs)
    {os &lt;&lt; "  Sequences object " &lt;&lt; endl;
    for (int i=0; i &lt; seqs.getListSize(); i++ )
        os &lt;&lt; "    " &lt;&lt; (i+1) &lt;&lt;":  " &lt;&lt; seqs.get( i ) &lt;&lt; endl;
    return os;
  
    }
  </code></pre>