
June 11th, 2003, 05:39 AM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 13
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Linkage error in template
Hi everyone,
I'm trying to make a template that looks like this:
Code:
//Declaration
template <class T>
class Vector
{
private:
T ** t;
public:
void add(T * t);
};
//Implementation (of Vector::add)
template <class T>
void Vector<T>::add(T * t)
{
ensureCapacity(length + 1);
entries[length++] = t;
}
Is there something wrong with this code? I get an "unresolved external symbol", for some reason. This is the exception:
Code:
xml error LNK2019: unresolved external symbol
"public: void __thiscall Vector<class XMLNode>::add(class XMLNode *)" (?add@?$Vector@VXMLNode@@@@QAEXPAVXMLNode@@@Z)
referenced in function "public: class Vector<class XMLNode> * __thiscall XMLNode::getElementsByTagName(char *)"
(?getElementsByTagName@XMLNode@@QAEPAV?$Vector@VXMLNode@@@@PAD@Z)
I understand that the error occures in void Vector::add(T*), which is referenced by Vector<XMLNode>XMLNode::getElementsByTagName(char*), but how can I solve it?
I get stuck and easily give up when I get these errors (their kind of hard to interpret). How am I supposed to solve these?
Thanks in advance,
Nille
PS
Sorry for asking a lot of questions.
|