title: How to return a pointer function?
body: <p>I'm new to c++, I'm asked for class work to do a function that takes a doubly linked list and copy it's elements into a singly linked list then returns it, however, I was given this function's declaration only, when I made the function it's either not returning anything or it gives me the error below, I understand the linked list code but I don't understand using a pointer and the returning part, can someone explain this to me? and how to make it work? I'm unable to find explanation to this online, or maybe I am searching the wrong keywords. Any help is appreciated.</p>
  
  <pre><code>template &lt;class T&gt;
  SinglyLinkedList&lt;T&gt;* DoublyLinkedList&lt;T&gt;:: Function() {
  
  SinglyLinkedList&lt;T&gt; list1;
  
  DLLnode&lt;T&gt;*p = head;
  
  while (p!=NULL) {
  
  list1.addtoHead(p-&gt;value);
  p=p-&gt;next;
  
  }
  
  return list1;
  
  }
  
  //error: cannot convert ‘SLL&lt;int&gt;’ to ‘SLL&lt;int&gt;*’ in return
  </code></pre>