Hi,
I have a miniproject in MVS2005 wich keeps bugging me with linking errors. I've read the documentation provided by MSV related to this error, and nothing seems to solve my problem.
So I came to you again for a helping hand.
ListaGenerica.h:
The ListaGenerica.cpp:Code:#include <iostream> using namespace std; template <class DataType> struct NodeList { DataType m_sData; NodeList* nxt; NodeList* prv; }; template <class DataType> class DLnkList { protected: NodeList<DataType>* pHead; public: DLnkList() { pHead = new NodeList<DataType>; pHead = NULL; } ~DLnkList() { while( pHead != NULL ) { NodeList<DataType>* pAux = pHead; pHead = pAux->nxt; delete pAux; cout<<"destr"; } } void AddNode(DataType Data); void ShowList(); };
And Main.cpp:Code:#include "ListaGenerica.h" #include <string> #include <iostream> using namespace std; template <class DataType> void DLnkList<DataType>::AddNode(DataType Data) { NodeList<DataType>* pNewNode = new NodeList<DataType>; pNewNode->nxt = pHead; pHead = pNewNode; pNewNode->m_sData = Data; } template <class DataType> void DLnkList<DataType>::ShowList() { NodeList<DataType>* pAux; pAux = pHead; while( pAux != NULL ) { cout << endl << pAux->m_sData; pAux = pAux->nxt; } }
and here are the errors:Code:#include "ListaGenerica.h" #include <string> #include <iostream> using namespace std; int main(void) { DLnkList<int>* ol = new DLnkList<int>; ol->AddNode(5555); ol->ShowList(); delete ol; }
When i copy the function definitions in main.cpp, te project builds. Why doesn't the builder see the ListaGenerica.cpp?Code:1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall DLnkList<int>::ShowList(void)" (?ShowList@?$DLnkList@H@@QAEXXZ) referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall DLnkList<int>::AddNode(int)" (?AddNode@?$DLnkList@H@@QAEXH@Z) referenced in function _main
Any hints?
Tank you.



LinkBack URL
About LinkBacks


