Hi. I'm trying to write series of classes using templates and am running into what must be a simple error. I'm a bit of a noob so I apologize in advance if this kind of question is not welcome here.
When I try to run the program below i get the following error during build (using Visual Studio).
Data Structures error LNK2019: unresolved external symbol "public: __thiscall DLNode<int>::DL Node<int>(int)" (??0?$DLNode@H@ @QAE@H@Z) referenced in function "public: void __thiscall DLList<int>::ad dNode(int)" (?addNode@?$DLL ist@H@@QAEXH@Z)
Note I left the header files out as I don't think the problem is there, but I can include if need be. Any explaination is appreciated:
When I try to run the program below i get the following error during build (using Visual Studio).
Data Structures error LNK2019: unresolved external symbol "public: __thiscall DLNode<int>::DL Node<int>(int)" (??0?$DLNode@H@ @QAE@H@Z) referenced in function "public: void __thiscall DLList<int>::ad dNode(int)" (?addNode@?$DLL ist@H@@QAEXH@Z)
Note I left the header files out as I don't think the problem is there, but I can include if need be. Any explaination is appreciated:
Code:
#include <stdio.h> #include "DLList.cpp" main(){ DLList<int> intlist; intlist.addNode(13); printf( "%d", intlist.getFirst() ); }
Code:
#include "DLList.h" template <class Type> DLList<Type>::DLList(){ first = 0; last = 0; } template <class Type> void DLList<Type>::addNode(Type a){ DLNode<int> intlist(a); first = &intlist; } template <class Type> Type DLList<Type>::getFirst(){ return first->getElement(); }
Code:
#include "DLNode.h" template <class Type> DLNode<Type>::DLNode(Type a){ data = a; } template <class Type> Type DLNode<Type>::getElement(){ return data; } template <class Type> void DLNode<Type>::setElement(Type a){ data = a; }
Comment