-1
我刚刚开始执行我的跳过列表,并且尝试了一切以摆脱此错误。我的构建成功,但是当我将“SList p”放入我的主程序时,它失败并且表示链接的引用ld错误。问题是什么?跳过列表实现C++ - XCode错误
这里是我的.h文件
#ifndef SLIST_H
#define SLIST_H
#include <string>
#include <fstream>
class SList {
public:
SList();
// overloaded assignment operator
SList& operator = (const SList&);
// copy constructor
SList(const SList&);
// destructor
~SList();
private:
const static int DUMMY_VALUE = -1000;
struct Node {
int data;
Node *next;
};
struct upperNode {
upperNode *next;
Node *down;
};
Node *head;
upperNode *upperHead;
int length;
};
#endif // SLIST_H
__
我.cpp文件
#include "SList.h"
SList::SList() {
length = 0;
head->data = DUMMY_VALUE;
head->next = nullptr;
upperHead->down = head;
upperHead->next = nullptr;
}
和我的主要
#include "SList.h"
#include <iostream>
int main() {
SList p;
return 0;
}
缺少什么我在这里?我觉得这非常明显,我只需要第二组眼睛。谢谢。
XCode通常不需要你输入一个Makefile –
有几种方法,比如你刚声明的析构函数,但从未实现它们。 –
顺便说一句,你应该包括确切的链接器错误消息,而不是像'链接引用ld错误'。 –