LNK 2019/1120我的头文件/源文件实践中的双重链接列表错误
LNK 2019 / 1120 Errors with my header / source file practice with Double Linked Lists
你能帮我弄清楚为什么我会收到这些2019错误吗?我确信所有的文件都保存在正确的位置,我认为我对头文件使用了正确的约定?这是我的系统编程课的实验室。
以下是错误:
1> main.obj:错误LNK2019:未解析的外部符号"public:__thiscall DLL::intDLL:,intDLL(void)"(??0intDLL@DLL@@QAE@XZ)在函数_main 中引用
1> main.obj:错误LNK2019:未解析的外部符号"public:__thiscall DLL::intDLL::~intDLL(void)"(??1intDLL@DLL@@QAE@XZ)在函数_main 中引用
1> main.obj:错误LNK2019:未解析的外部符号"public:void__thiscall DLL::intDLL:"addFront(int)"(?addFront@intDLL@DLL@@QAEXH@Z)在函数_main 中引用
1> main.obj:错误LNK2019:未解析的外部符号"public:int__thiscall DLL::intDLL:"getFront(void)"(?getFront@intDLL@DLL@@QAEHXZ)在函数_main 中引用
1> c:\users\josh\documents\visualstudio2012\Projects\Lab10\Debug\Lab10.exe:致命错误LNK1120:4未解析外部
intDLL.h文件:
#include <iostream>
using std::cout;
using std::endl;
class intDLL {
public:
intDLL();
intDLL(const intDLL &original);
~intDLL();
void addFront(int inValue);
void addBack(int inValue);
void setBack();
int getFront();
int getBack();
struct node {
int value;
node *next;
node *prev;
};
private:
node *front;
node *back;
};
intDLL.cpp
#include <iostream>
#include "intDLL.h"
using std::cout;
using std::endl;
intDLL::intDLL() {
front = 0;
back = 0;
}
void intDLL::setBack() {
node *tempNode = new node;
if(front == 0) {
return;
}
tempNode = front;
while(tempNode->back != 0) {
tempNode = tempNode->prev;
}
back = tempNode;
}
void intDLL::addFront(int inValue) {
if(front == 0) {
node *newFront = new node;
newFront->value = inValue;
newFront->next = 0;
newFront->prev = 0;
}
else {
node *newFront = new node;
newFront->value = inValue;
newFront->prev = front;
front->next = newFront;
newFront->next = 0;
front = newFront;
}
setBack();
}
void intDLL::addBack(int inValue) {
setBack();
node *newBack = new node;
newBack -> value = inValue;
back->prev = newBack;
newBack->next = back;
back = newBack;
}
int intDLL::getFront() {
return front->value;
}
int intDLL::getBack() {
return back->value;
}
main:
#include <iostream>
#include "intDLL.h"
using std::cout;
using std::endl;
int main(int argc, char* argv[]) {
intDLL test = intDLL();
test.addFront(3);
test.addFront(4);
test.addFront(5);
std::cout << test.getFront() << endl;
return 0;
}
不确定真正的错误消息是什么,但似乎还没有实现一些函数,例如示例
intDLL(const intDLL &original);
~intDLL();
检查函数定义,确保声明的每个函数都已定义。还要确保所有cpp文件都已编译并链接。
另一个错误是intDLL::node
没有后台成员
void intDLL::setBack() {
intDLL::node *tempNode = new node;
^^^^ node is defined in intDLL, you need provide scope
if(front == 0) {
return;
}
tempNode = front;
while(tempNode->back != 0) {
^^^ intDLL::node has no back member
tempNode = tempNode->prev;
}
back = tempNode;
}
请参阅此SO链接。
- emplace_back初始化列表错误,当初始化列表在独立变量上工作时
- GDB 列表错误"No such file or directory"
- 数组初始值设定项必须是初始值设定项列表错误未显示
- 成员初始值设定项列表错误的统一初始化
- C 模板二进制搜索树 - 参数列表错误
- 链接列表错误 - 为什么头和尾引用指向相同地址
- 没有与参数列表错误匹配的重载函数" "实例
- C 链接列表错误:lvalue作为分配的左操作数所需
- 嵌套模板列表错误
- 邻接列表错误与列表
- 函数调用缺少参数列表错误
- 迭代子类列表错误
- gcc 中的初始化列表错误
- 转到下一个节点的C++链接列表错误
- 奇怪的模板参数列表错误太少
- 链接列表错误,c++
- c++循环列表错误
- Coderunner 2 -初始化列表错误- c++ 11
- 没有函数模板实例匹配参数列表错误
- 删除列表错误中的最后一个节点