Thought i would do lists using templates and here is my header, note this is for a singly linked list and theres no comments in it yet and may be a little messy
//E_Lists.h
#ifndef E_LISTS
#define E_LISTS
template <class T> class E_Node
{
protected:
T data;
E_Node *next;
};
template <class T> class E_SingleList
{
protected:
E_Node<T> *head;
E_Node<T> *current;
int numberOfNodes;
public:
//constructor(s) / destructor
void Create();
void StartIterator();
void MoveForward();
T GetCurrentItem();
bool IsIteratorValid();
void InsertItem(T item);
void RemoveCurrentItem();
void AppendItem(T item);
int GetNumberOfNodes();
};
#endif
heres some source of the implementation
//E_Lists.cpp
#include "E_Lists.h"
template <class T> void E_SingleList<T>::Create()
{
head = NULL;
current = NULL;
numberOfNodes = 0;
}
template <class T> void E_SingleList<T>::StartIterator()
{
current = head;
}
template <class T> void E_SingleList<T>::MoveForward()
{
if(IsIteratorValid())
{
current = current->next;
}
}
template <class T> T E_SingleList<T>::GetCurrentItem()
{
return current->data;
}
dont think the rest is relevent.
Right now I declare a list like this:
E_SingleList list;
then in my program i use it like this
list.Create();
and it comes up with a compiler error saying
E_App.obj : error LNK2001: unresolved external symbol "public: void __thiscall E_SingleList::Create(void)" (?Create@?$E_SingleList@H@@QAEXXZ)
D
anyone know whats wrong?