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>::DLNode<int>(int)" (??0?$DLNode@H@@QAE@H@Z) referenced in function "public: void __thiscall DLList<int>::addNode(int)" (?addNode@?$DLList@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:
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include "DLList.cpp"
- main(){
- DLList<int> intlist;
- intlist.addNode(13);
- printf( "%d", intlist.getFirst() );
- }
Expand|Select|Wrap|Line Numbers
- #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();
- }
Expand|Select|Wrap|Line Numbers
- #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;
- }