i'm trying to develop a template for a linked list. This is the first template i've ever worked on...
Here's the header for it:
struct LISTDATA_TYP
{
public:
LISTDATA_TYP();
~LISTDATA_TYP();
void *m_pData;
int m_nNodeID;
void* m_pNextNode;
void* m_pPrevNode;
};
template class T class LinkedListTemplate
{
public:
LinkedListTemplate() {m_iListElementIndex = 0;}
~LinkedListTemplate() {DestroyList();}
int InsertElementInList(void *pDataElement);
int DeleteElementInList(long nID);
T* FindNodeInList(long nSearchNodeID);
protected:
int AddNewNode(T* pNewNode);
void RemoveNode(T* pDeleteNode);
long SetNewListElementID();
void DestroyList();
LISTDATA_TYP ListData;
T *m_pHeadNode;
T *m_pTailNode;
long m_iListElementIndex;
};
And, in another file (called main.h):
LinkedListTemplate long LinkedList;
When i compile, i get the error:
main.obj : error LNK2001: unresolved external symbol "protected: void __thiscall LinkedListTemplate long ::DestroyList(void)" (?DestroyList@?$LinkedListTemplate@J@@IAEXXZ)
i couldn't get the arrow symbols surrounding class T to come through on this post, nor around long in the main.h file. But they are there.
i also declare the functions in the source file like this:
template class T
T* LinkedListTemplate T ::FindNodeInList(long nSearchNodeID)
Again, the arrows around class T and T don't come through...
i know what the error means, but i don't know how to fix it.
i originally had the constructor and destructor in the body of the source file instead of the header, but i kept getting the above header for both, so i tried to simplify them in the header file.
Any suggestions? Thanks!
"You call him Dr. Grip, doll!"
Edited by - the_grip on July 30, 2001 8:58:28 AM
"You call him Dr. Grip, doll!"