Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/145.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ LNK 2019/1120我的头文件/源文件错误使用双链接列表的做法_C++_Header_Lnk2019 - Fatal编程技术网

C++ LNK 2019/1120我的头文件/源文件错误使用双链接列表的做法

C++ LNK 2019/1120我的头文件/源文件错误使用双链接列表的做法,c++,header,lnk2019,C++,Header,Lnk2019,你能帮我弄清楚为什么会出现这些错误吗?我很确定所有文件都保存在正确的位置,我想我对头文件使用了正确的约定?这是我的系统编程课的实验室 以下是错误: 1> main.obj:错误LNK2019:未解析的外部符号“public: __此调用DLL::intDLL::intDLL(无效)“(??)??0intDLL@DLL@@QAE@XZ)在函数_main中引用 1> main.obj:错误LNK2019:未解析的外部符号“public: __此调用DLL::intDLL::~intDLL(void)

你能帮我弄清楚为什么会出现这些错误吗?我很确定所有文件都保存在正确的位置,我想我对头文件使用了正确的约定?这是我的系统编程课的实验室

以下是错误:

1> main.obj:错误LNK2019:未解析的外部符号“public: __此调用DLL::intDLL::intDLL(无效)“(??)??0intDLL@DLL@@QAE@XZ)在函数_main中引用

1> main.obj:错误LNK2019:未解析的外部符号“public: __此调用DLL::intDLL::~intDLL(void)“(?)??1intDLL@DLL@@QAE@XZ)在函数_main中引用

1> main.obj:错误LNK2019:未解析的外部符号“public:void” __此调用DLL::intDLL::addFront(int)“(?)?addFront@intDLL@动态链接库@@QAEXH@Z)在函数_main中引用

1> main.obj:错误LNK2019:未解析的外部符号“public:int” __此调用DLL::intDLL::getFront(无效)“(?)?getFront@intDLL@DLL@@QAEHXZ)在函数\u main中引用

1> c:\users\josh\documents\visual studio 2012\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;

};
#包括
使用std::cout;
使用std::endl;
类intDLL{
公众:
intDLL();
intDLL(常量intDLL和原件);
~intDLL();
无效地址(无效);
无效回拨(无效);
无效挫折();
int getFront();
int getBack();
结构节点{
int值;
节点*下一步;
节点*prev;
};
私人:
节点*前端;
节点*返回;
};
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;
}
#包括
#包括“intDLL.h”
使用std::cout;
使用std::endl;
intDLL::intDLL(){
正面=0;
后退=0;
}
void intDLL::setBack(){
node*tempNode=新节点;
如果(前==0){
返回;
}
tempNode=前面;
while(tempNode->back!=0){
tempNode=tempNode->prev;
}
返回=临时节点;
}
void intDLL::addFront(int inValue){
如果(前==0){
node*newFront=新节点;
newFront->value=无效;
newFront->next=0;
newFront->prev=0;
}
否则{
node*newFront=新节点;
newFront->value=无效;
newFront->prev=front;
front->next=newFront;
newFront->next=0;
front=newFront;
}
挫折();
}
void intDLL::addBack(int inValue){
挫折();
node*newBack=新节点;
新备份->值=无效;
后退->后退=新后退;
newBack->next=返回;
后退=新后退;
}
int intDLL::getFront(){
返回前端->值;
}
int intDLL::getBack(){
返回->值;
}
主要内容:

#包括
#包括“intDLL.h”
使用std::cout;
使用std::endl;
int main(int argc,char*argv[]){
intDLL test=intDLL();
试验。添加正面(3);
试验。添加前(4);
试验。添加正面(5);

std::cout不确定真正的错误消息是什么,但对于示例来说,似乎您还没有实现一些函数

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;
}

查看此链接。

请显示完整的错误消息。我从
LNK2019
得到的唯一提示是,它必须与链接器相关。添加了错误消息。为什么在我的第一篇帖子上投反对票?:(因为只是输出原始代码并说“我有错误消息”不是很好。删除了downvote。但是你仍然应该添加一些细节,比如你如何编译itI。我注释掉了头文件中声明的那些未使用的函数(因为这些错误,还没有编写它们),并得到了相同的最后3条错误消息。我假设当我“不调试启动”时在VisualStudio2012中,它编译了项目中的所有文件并进行了适当的链接。不是这样吗?
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;
}