title: Pop function on Linked list stack
body: <p>Hello I have a problem to returned variable from my pop function.
  I will be happy if you could help me.
  The function receives a pointer to the top of the list and should return the answer but I have a problem with a pointer to the list and intger the answer.</p>
  
  <p>Function Code - </p>
  
  <pre><code>int pop(Node* top)
  {
      Node* tmp = top;
      int ans = tmp-&gt;next;
      top = top-&gt;next;
      delete tmp;
      return ans;
  }
  </code></pre>
  
  <p>Node -</p>
  
  <pre><code>struct Node
  {
  int num;
  Node* next;
  }
  
  
  Node* top = new Node;
  </code></pre>