I don't want to post to much of my code up, because there is a lot, but I'm not sure where to start.
My project is simply to make a Doubly Linked list in C++. I've been working on the same project for weeks because of this one error. Its quite frustrating:
Code:
1>main.obj : error LNK2019: unresolved external symbol "public: class DLNode<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __thiscall DLNode<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::getPredecessor(void)" (?getPredecessor@?$DLNode@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAEPAV1@XZ) referenced in function "public: void __thiscall DoublyLinkedList<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::addAtTail(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?addAtTail@?$DoublyLinkedList@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>C:\Users\Nick\Documents\Visual Studio 2008\Projects\NewDoublyLinkedList\Debug\NewDoublyLinkedList.exe : fatal error LNK1120: 1 unresolved externals
the basic layout of the program is:
first header file contains a class (and its methods) called SLNode (stands for Singly Linked Node). It has contains a pointer to an SLNode called successor and also a reference to whatever element is being stored. (using generics)
second header file conatains a DLNode class. it contains to pointer to a DLNode called predecessor. DLNode inherits SLNode.
third header file contains a class DoublyLinkedList. It contains (among other things) a method called addAtTail, which is where this error seems to come from.
DLNode has a getPredecessor and setPredecessor method aswell as getSuccessor and setSuccessor method via inheritance through the SLNode class.
Here is some code of possible value, if you need more, let me know:
Code:
template <class E>
void DoublyLinkedList<E>::addAtTail(E theElement)
{
DLNode<E> newNode(theElement);
DLNode<E> *previousNode = tail.getPredecessor(); //returns a pointer
newNode.setSuccessor(&tail);
newNode.setPredecessor(previousNode);
previousNode->setSuccessor(&newNode);
tail.setPredecessor(&newNode);
}
Code:
template <class E>
DLNode<E> DLNode<E>::*getPredecessor()
{
return this->predecessor;
}