title: Node Class to represent a binary tree C++
body: <p>I have created a node.h class, defining a class called node for representing a binary tree(any type). It seems to be that the constructor isn't working. The errors are below.Ive only started writing constructors within classes like these, and this is the first ive encountered binary trees. Can anyone point me in the right direction on how to fix these errors and make my code work? Thanks.
  <a href="https://i.stack.imgur.com/Fbx6y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fbx6y.png" alt="enter image description here"></a></p>
  
  <p>Node.h</p>
  
  <pre><code>#ifndef NODE_H
  #define NODE_H
  #include &lt;iostream&gt;
  
  //an object of type node holds 3 things
  // - an item (oftype t)
  // - a left subtree
  // - a right subtree
  
  template&lt;typename T&gt;
  class Node {
  public:
      Node(T item); //constructor to create a leaf node
      Node(T item, Node *lft, Node *rht); //constructor which creates an internal node 
      ~Node(); //Destructor
  
      //public data member functions:
      bool searchTree(T key);
      void printTree();
  
  private:
      //private data member functions:
      //..
  };
  
  //constructor 
  template&lt;typename T&gt;
  Node&lt;T&gt;::Node(T i, Node&lt;T&gt; *l, Node&lt;T&gt; *r) {
      item = i;
      lft = NULL;
      rht = NULL;
  }
  
  //constructor //is this correct?
  template &lt;typename T&gt;
  Node&lt;T&gt;::Node(T i) { //should i be a parameter here?
      item = i; //is this right?
  }
  
  //destructor
  template &lt;typename T&gt;
  Node&lt;T&gt;::~Node() {
      delete left;
      delete right;
      //delete;
  }
  
  
  //print tree method
  template &lt;typename T&gt;
  void Node&lt;T&gt;::printTree() {
      if (lft != NULL) {
          lft-&gt;printTree();
          cout &lt;&lt; item &lt;&lt; endl;//alphabetical order
      }
  
      if (rht != NULL) {
          rht-&gt;printTree();
          //cout &lt;&lt; item &lt;&lt; endl; //post order
      }
  }
  
  //search Tree method
  template &lt;typename T&gt;
  bool Node&lt;T&gt;::searchTree(T key) {
      bool found = false;
      if (item == key) {
          return true;
      }
      if (left != NULL) {
          found = left-&gt;searchTree(key);
          if (found) return true;
      }
      if (right != NULL) {
          return right-&gt;searchTree(key);
      }
      return false; //if left and right are both null &amp; key is not the search item, then not found == not in the tree.
  }
  
  #endif
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>#include "Node.h"
  #include &lt;iostream&gt;
  using namespace std;
  
  //set up tree method
  Node&lt;string&gt; *setUpTree() {
      Node&lt;string&gt; *s_tree =
          new Node&lt;string&gt;("Sunday",
          new Node&lt;string&gt;("monday",
          new Node&lt;string&gt;("Friday"),
          new Node&lt;string&gt;("Saturday")),
          new Node&lt;string&gt;("Tuesday",
          new Node&lt;string&gt;("Thursday"),
          new Node&lt;string&gt;("Wednesday")));
  }
  
  int main() {
  
      Node&lt;string&gt; *s_tree;
      s_tree = setUpTree();
  
      cout &lt;&lt; "Part 2 :Priting tree vals " &lt;&lt; endl &lt;&lt; endl;
      s_tree-&gt;printTree();
      cout &lt;&lt; endl;
  
      //search for range of tree values
      //searchTree(s_tree, "Sunday");
      //searchTree(s_tree, "Monday");
  
      return 0;
  }
  </code></pre>