Singly linked list - c++ class template

I have to make a class of singly linked list:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
template <class T> class LINKED_LIST {
private:
struct ListNode 
{
T data; 
ListNode *next; 
};
UINT size; 
ListNode *head; 

public:
LINKED_LIST(); 
LINKED_LIST(const LINKED_LIST &aList); 
~LINKED_LIST(); 
// operations
bool isEmpty();
UINT getLength();
int insert(UINT index, T newItem); // insert after “index”
int remove(UINT index); // 0: fail 1: success
UINT findNode(T key); // node index or -1
int retrieve(UINT index, T &itemData); // 0,1 fail,success
};


i wonder where the ListNode *tail is

thks!!!
i wonder where the ListNode *tail is
I believe this specific class doesn't have a tail pointer, instead it goes trough items in node list and tries to find an element based on index.
Single linked lists usually don't have a tail pointers.
if there is no tail
so if i wanna initialize a list
i just

 
head = NULL


????
Yeah..
But i ve studied that singly linked list includes head and tail

Now without tail, everything alright???
It's possible both with and without a tail pointer. There are pros and cons to both ways.
It can work without the tail pointer.
In case you don't often need to add new elements to the end it's not really important.
Usually algorithms just go from one element to the other till the end, so they don't need to know the address of the last one.
thank you!!!!
Topic archived. No new replies allowed.