title: Print LinkedList Recursively using C++
body: <p>I'm trying to create a function that would print out my link list recursively, but I'm having trouble doing that, because recursion is just hard.</p>
  
  <p>This is the function I wrote, obviously takes a parameter, but I don't know how to pass it. And probably the output is wrong. </p>
  
  <p>I used typedef: </p>
  
  <pre><code> typedef struct node* nodePtr;
  </code></pre>
  
  <p>and thanks to the input from one of the guys, I updated my function to look like this, but now visual studio is giving an error that says:</p>
  
  <p>"Declaration is incompatible with void List::PrintListRecursively", so I wonder that the way I pass the parameter is just a slight different.</p>
  
  <p>thank you in advance</p>
  
  <pre><code>void List::PrintListRecursively(nodePtr curr ){
  
      if (curr==NULL)
      {
          cout &lt;&lt; "\n";
          return;
      }
      cout &lt;&lt; curr-&gt;data &lt;&lt;endl;
      PrintListRecursively(curr-&gt;next);
  
  
  }
  </code></pre>
  
  <p>I wrote the same function not recursively:</p>
  
  <pre><code>void List::PrintList(){
      curr = head;
      while(curr != NULL)
      {
          cout &lt;&lt; curr-&gt;data &lt;&lt;endl;
          curr = curr-&gt;next;
      }
  }
  </code></pre>
  
  <p>and this one works great. Could somebody help out with the recursion part and help me find out whats wrong. Don't be too mean.</p>