if i have the following node class
class Node {
public:
Node() { next = NULL; prev = NULL; }
~Node() {}
public :
Node *next;
Node *prev;
T data;
};
how do i create an empty linked list in the function
LinkedList::LinkedList()
my linked list classs has the following functions
void append(T item);
T get(int idx);
void insert(int idx, T item);
void map(T (*pf)(T item));
T remove(int index);
int size();
void unshift(T item);
Doubly linked lists usually have a reference to the first and (sometimes) last element in the list.
In your constructor, just set these to
NULL. Then make anisEmptymethod which checks for this condition, and you’re done.