title: Why passing a pointer by reference here causes an error?
body: <p>I have a template node class:</p>
  <pre><code>template&lt;typename T&gt;
  class TNode {
      T data;
      TNode&lt;T&gt;* left;
      TNode&lt;T&gt;* right;
  public:
      TNode() {   left = right = nullptr; }
      TNode(T d) {    data = d;   left = right = nullptr; }
      void setData(T d) { data = d; }
      T getData() {   return data;    }
      void setLeft(TNode&lt;T&gt;* l) {     left = l;   }
      TNode&lt;T&gt;* getLeft() {   return left;    }
      void setRight(TNode&lt;T&gt;* r) {    right = r;  }
      TNode&lt;T&gt;* getRight() {  return right;   }
  };
  </code></pre>
  <p>Which I am using to build the following binary search tree :</p>
  <pre><code>template&lt;typename T&gt;
  class BSTree
  {
  private:
      TNode&lt;T&gt;* root;
      void rec_insertBST(TNode&lt;T&gt;*&amp; subRoot, int key)
      {
          if (subRoot == nullptr)
              subRoot = new TNode&lt;T&gt;(key);
          else if (subRoot-&gt;getData() &lt; key)
              rec_insertBST(subRoot-&gt;getRight(), key);
          else
              rec_insertBST(subRoot-&gt;getLeft(), key);
      }
  public:
      void insertBST(int key)
      {
          rec_insertBST(root, key);
      }
  };
  </code></pre>
  <p>when I pass pointer to insert function by reference (<strong>&amp;</strong>) I get this compilation error :</p>
  <blockquote>
  <p>'void BSTree::rec_insertBST(TNode *&amp;,int)': cannot convert
  argument 1 from 'TNode *' to 'TNode *&amp;'</p>
  </blockquote>
  <p>But when I remove the reference operator (<strong>&amp;</strong>) It compiles successfully. Why does this happen and how can I pass pointer by reference here ?</p>
  <p>Even if the code doesn't make sense I want explanation for the error please.</p>