全部,我正在实现LinkedList并遇到以下错误。据我搜索,以前没有问过这个问题。未解析的外部符号是什么意思?这是一个Win32控制台应用程序。任何帮助,将不胜感激。为代码格式提前道歉。我还没想到它。
LNK2019未解析的外部符号" public:void __thiscall List :: push_front(int const&)" (?push_front @?$ List @ H @@ QAEXABH @ Z)在函数_main
中引用List.cpp
#include "stdafx.h"
#include "List.h"
#include "Node.h"
template <typename Type>
List<Type>::List()
{
head = NULL;
tail = NULL;
count = 0;
}
template <typename Type>
List<Type>::~List()
{
}
template <typename Type>
bool List<Type>::empty()
{
return count == 0;
}
template <typename Type>
int List<Type>::size()
{
return count;
}
template <typename Type>
void List<Type>::push_front(const Type &d)
{
Node *new_head = new Node(d, NULL, head);
if (this->empty())
{
head = new_head;
tail = new_head;
}
else
{
head->prev = new_head;
head = new_head;
}
count++;
}
template <typename Type>
void List<Type>::push_back(const Type &d)
{
Node *new_tail = new Node(d, NULL, tail);
if (this->empty())
{
head = new_tail;
tail = new_tail;
}
else
{
tail->next = new_tail;
tail = new_tail;
}
count++;
}
template <typename Type>
void List<Type>::DisplayContents()
{
Node *current = head;
for (int i = 0; i <= this->size; i++)
{
cout << current->data << " ";
current = current->next;
}
}
</pre></code>
LinkedList.cpp
#include "stdafx.h"
#include "List.h"
int main()
{
List<int> listIntegers;
listIntegers.push_front(10);
listIntegers.push_front(2011);
listIntegers.push_back(-1);
listIntegers.push_back(9999);
listIntegers.DisplayContents();
return 0;
}