I have declared and defined the class LinkedList as:
I am finding it difficult to define the constructor for the List class. I have something like this:
The code is compiling with no errors. But, the linker is giving the following error message for the following code:
linker error:
Please help me in resolving this.
Regards,
Anirudh
Code:
template <class T> class LinkedList { private: class List { public: List(T& aEle); public: T& iEle; List* iNext; }; List* iHeader; List* iCurrent; public: LinkedList(); // Member functions };
Code:
template <class T> LinkedList<T>::List::List(T& aEle):iEle(aEle),iNext(NULL) { } // Definition of other member functions
Code:
int main() { LinkedList<int> list; return 0; }
Code:
linkedlist.obj : error LNK2001: unresolved external symbol "public: __thiscall LinkedList<int>::List::List(int &)" (??0List@?$LinkedList@H@@QAE@AAH@Z) Debug/linkedlist.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe.
Regards,
Anirudh
Comment