How to return a pointer ?
Now I am unsure about how to do below as Iam fairly new to C++ Iâm trying to do a function that returns a linked list, however in the method, I am asked to do, the return type includes a pointer // copying the values from the doubly linked list to the singly linked list then returns the singly linked list. However, itâs not returning anything, what am I doing wrong? SinglyLinkedList<T>* DoublyLinkedList<T>:: Function() { SinglyLinkedList<T> list1; DLLnode<T>*p = head; while ( p!= NULL ) { list1.addtoHead(p->value); p=p->next; } Return list1; } For example Original doubly linked list 1 <=> 2 <=> 3 The returned singly linked list 1 -> 2 -> 3 error message given: *cannot convert SinglyLinkedList<int> to SinglyLinkedList<int>* in return