template <class T>
class LINKED_LIST
{
private:
struct ListNode
{
T data;
ListNode *next; // pointer to next node
};
unsignedint size; // number of node in list
ListNode *head;
public:
LINKED_LIST();
LINKED_LIST(const LINKED_LIST &aList); // copy constructor
// operations
bool isEmpty();
int insert(unsignedint index, T newItem); // insert after “index”
........
};
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
template <class T>
LINKED_LIST<T>::LINKED_LIST(const LINKED_LIST &aList)
{
size = 0;
head = NULL;
ListNode *p = aList.head;
unsignedint i = 0;
while (p != NULL)
{
this->insert(i,p->data);
p = p->next;
i++;
}
}