-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錯誤'。 –