title: c++ undefined symbol when compiling
body: <p><strong>FIXED: had the method twice in the header file</strong></p>
  
  <p>I get the following error when trying to compile my project</p>
  
  <pre><code>% make
  g++ -o p4 testTree.o tree.o node.o check.o
  Undefined                       first referenced
   symbol                             in file
  Tree::inTree(int)                   tree.o
  ld: fatal: Symbol referencing errors. No output written to p4
  collect2: ld returned 1 exit status
  *** Error code 1
  make: Fatal error: Command failed for target `p4'
  </code></pre>
  
  <p><strong>Makefile</strong></p>
  
  <pre><code>p4: testTree.o tree.o node.o check.o
      g++ -o p4 testTree.o tree.o node.o check.o
  testTree.o: testTree.cc tree.h node.h check.h
      g++ -c -Wall -Werror testTree.cc
  
  tree.o: tree.h tree.cc node.h check.h
      g++ -c -Wall -Werror tree.cc
  node.o: node.h node.cc check.h
      g++ -c -Wall -Werror node.cc
  check.o: check.h check.cc
      g++ -c -Wall -Werror check.cc
  clean:
      rm -f *~ *.o p4
  </code></pre>
  
  <p>Relevant code from tree.cc and tree.h:</p>
  
  <p><strong>tree.cc</strong></p>
  
  <pre><code>...
  bool Tree::inTree(int k) const
  {
       return locate(k,root) != NULL;
  }
  ...
  </code></pre>
  
  <p><strong>tree.h</strong></p>
  
  <pre><code>#ifndef TREE_H
  #define TREE_H
  
  #include "node.h"
  #include "check.h"
  using namespace std;
  class Tree
  {
    private:
      Node *root;
    public:
      Tree();
      Tree(const Tree &amp; t);
      const Tree &amp; operator=(const Tree &amp;t);
      friend ostream &amp; operator&lt;&lt;(ostream &amp;out, const Tree &amp;t);
      bool inTree(int k) const;
      double &amp; operator[](int k);
      double &amp; operator[](int k) const;
      ~Tree();
      bool inTree(int index);
    private:
      Node * locate(int k, Node *rt) const;
      ostream &amp; display(ostream &amp;out, Node *r, int dir=Node::L) const;
      void add(int k, Node*&amp;r);
      void kill(Node *&amp;rt);
      void copy(Node *rt, Node *&amp;newRt);
  };
  #endif
  </code></pre>
  
  <p>I get the feeling that it's something really simple, but I can't seem to figure it out. </p>