title: Summing up the elements in a linked list recursively in C++
body: <p>Suppose I have a Sum method to help sum the elements in a linked list recursively, </p>
  
  <pre><code>void Sum(Node *head)
  {
      int sum = 0;   //I think this is the problem since it resets the sum on each recursive call
      while (head != NULL) {
          Sum(head-&gt;next); //iterate to the last node before null
          sum += head-&gt;data; 
          return;
      }
  
      cout &lt;&lt; " The sum is : " &lt;&lt; sum &lt;&lt; endl;
  }
  </code></pre>
  
  <p>The issue I'm having is I think due to my sum value being reinitialized to 0 with each recursive back call; what is a way to allow me to maintain the value of the sum once all the recursion is complete?</p>