C
cyberdave
Someone please help me!
I have a template class like this:
--------------------------------------------------
template<typename T>
class List
{
public:
...
// Nested Class
class Node
{
public:
...
void setPreviousNode(Node* pnNode);
void setNextNode(Node* pnNode);
private:
// Data Members
T m_sData;
Node* m_pnPreviousNode;
Node* m_pnNextNode;
....
};
....
template<typename T>
void List<T>::Node::setPreviousNode(Node* pnNode)
{
m_pnPreviousNode = pnNode;
}
template<typename T>
void List<T>:ushBack(T sString)
{
...
pnNewNode->setPreviousNode(m_pnLastNode);
m_pnLastNode->setNextNode(pnNewNode);
...
}
....
int main()
{
List<int> i;
i.pushBack(1);
i.pushBack(2);
i.pushBack(3);
i.pushBack(4);
return 0;
}
--------------------------------------------------
I can compile it (I'm using VC++ 6.0). But when I try to link it, it
gave me:
Main.obj : error LNK2001: unresolved external symbol "public: void
__thiscall List<int>::Node::setNextNode(class List<int>::Node *)"
(?setNextNode@Node@?$List@H@@QAEXPAV12@@Z)
Main.obj : error LNK2001: unresolved external symbol "public: void
__thiscall List<int>::Node::setPreviousNode(class List<int>::Node *)"
(?setPreviousNode@Node@?$List@H@@QAEXPAV12@@Z)
Main.obj : error LNK2001: unresolved external symbol "public:
__thiscall List<int>::Node::Node(int)" (??0Node@?$List@H@@QAE@H@Z)
I think it has something to do with my setNextNode and setPreviousNode.
Since Node is nested in the template class List, how do I pass it as a
parameter? Did I declare it correctly? Thanks.
--DK
I have a template class like this:
--------------------------------------------------
template<typename T>
class List
{
public:
...
// Nested Class
class Node
{
public:
...
void setPreviousNode(Node* pnNode);
void setNextNode(Node* pnNode);
private:
// Data Members
T m_sData;
Node* m_pnPreviousNode;
Node* m_pnNextNode;
....
};
....
template<typename T>
void List<T>::Node::setPreviousNode(Node* pnNode)
{
m_pnPreviousNode = pnNode;
}
template<typename T>
void List<T>:ushBack(T sString)
{
...
pnNewNode->setPreviousNode(m_pnLastNode);
m_pnLastNode->setNextNode(pnNewNode);
...
}
....
int main()
{
List<int> i;
i.pushBack(1);
i.pushBack(2);
i.pushBack(3);
i.pushBack(4);
return 0;
}
--------------------------------------------------
I can compile it (I'm using VC++ 6.0). But when I try to link it, it
gave me:
Main.obj : error LNK2001: unresolved external symbol "public: void
__thiscall List<int>::Node::setNextNode(class List<int>::Node *)"
(?setNextNode@Node@?$List@H@@QAEXPAV12@@Z)
Main.obj : error LNK2001: unresolved external symbol "public: void
__thiscall List<int>::Node::setPreviousNode(class List<int>::Node *)"
(?setPreviousNode@Node@?$List@H@@QAEXPAV12@@Z)
Main.obj : error LNK2001: unresolved external symbol "public:
__thiscall List<int>::Node::Node(int)" (??0Node@?$List@H@@QAE@H@Z)
I think it has something to do with my setNextNode and setPreviousNode.
Since Node is nested in the template class List, how do I pass it as a
parameter? Did I declare it correctly? Thanks.
--DK