title: Why isn't my remove node function working?
body: <p>I've checked the boards and could not find any help with this. I find it easy to implement recursive functions given base and general cases, but this doesn't work the way I do it. I'm supposed to iterate down a list until I reach the tail of a linked list. If the next node is NULL, then I have to store the value at the last node, remove that node, and return the value. So it's similar to a dequeue method, except it's performed recursively. What am I doing wrong? </p>
  
  <pre><code>int LinkedList::removeTailRec(Node *n)
  {
      // check for the base case(s)
      if(n-&gt;next == NULL)
      {
          Node *tmp = new Node();
          tmp = n;
          int val = n-&gt;value;
          tmp = NULL;
          return val;
      }
      else
          return removeTailRec(n-&gt;next);
  
      // else call the recursive method
  }
  </code></pre>