C++ Xcode 10.0:链接器命令失败,退出代码为1(使用-v查看调用)
用下面的代码创建了一个新的Xcode cpp项目,它给了我一个响亮的错误“Linker command failed with exit code 1” 我试着在现有的Xcode项目中运行它,它成功地构建了,但是当我在现有的Xcode项目中运行它,或者创建一个新项目并复制粘贴此代码时,同样的问题出现了。我也尝试过研究其他关于这个错误的StackOverflow帖子,但似乎没有任何具体的方法来找到解决方案C++ Xcode 10.0:链接器命令失败,退出代码为1(使用-v查看调用),c++,xcode,clang++,xcode10,C++,Xcode,Clang++,Xcode10,用下面的代码创建了一个新的Xcode cpp项目,它给了我一个响亮的错误“Linker command failed with exit code 1” 我试着在现有的Xcode项目中运行它,它成功地构建了,但是当我在现有的Xcode项目中运行它,或者创建一个新项目并复制粘贴此代码时,同样的问题出现了。我也尝试过研究其他关于这个错误的StackOverflow帖子,但似乎没有任何具体的方法来找到解决方案 #include <iostream> #include <stdio.h
#include <iostream>
#include <stdio.h>
using namespace std;
class LList{
private:
//Represents each node in the LL
struct ListNode{
int data;
ListNode* next;
};
typedef struct ListNode* nodePtr;
nodePtr head, current, temp;
public:
LList();
void Insert(int addData) {
nodePtr n = new ListNode;
n->next = NULL;
n->data = addData;
if(head != NULL){
current = head;
while(current->next != NULL){
current = current->next;
}
current->next = n;
}
else{
head = n;
}
};
void Remove(int removeData) {
nodePtr delPtr = NULL;
temp = head;
current = head;
while(current != NULL && current->data != removeData){
temp = current;
current = current->next;
}
if(current == NULL){
cout << removeData << " was not in the list\n";
delete delPtr;
}
else{
delPtr = current;
current = current->next;
temp->next = current;
if(delPtr == head){
head = head->next;
temp = NULL;
}
delete delPtr;
cout << "The value " << removeData << " was deleted\n";
}
};
void PrintList() {
current = head;
while(current != NULL){
cout << current->data << " - ";
current = current->next;
}
cout << "\n";
};
LList::ListNode* middleNode(LList::ListNode* head) {
LList::ListNode* fastPtr = head;
LList::ListNode* slowPtr = head;
while(fastPtr->next != NULL){
fastPtr = fastPtr->next;
if(fastPtr->next != NULL){
fastPtr = fastPtr->next;
}
slowPtr = slowPtr->next;
}
return slowPtr;
};
};
int main() {
LList Aj;
Aj.Insert(5);
Aj.Insert(8);
Aj.Insert(10);
Aj.PrintList();
Aj.Remove(8);
Aj.PrintList();
Aj.Remove(5);
Aj.PrintList();
}
#包括
#包括
使用名称空间std;
类利斯特{
私人:
//表示LL中的每个节点
结构列表节点{
int数据;
ListNode*下一步;
};
typedef结构ListNode*nodePtr;
节点接收头、电流、温度;
公众:
李斯特();
无效插入(int addData){
nodePtr n=新的ListNode;
n->next=NULL;
n->data=addData;
if(head!=NULL){
电流=水头;
while(当前->下一步!=NULL){
当前=当前->下一步;
}
当前->下一步=n;
}
否则{
水头=n;
}
};
无效删除(int-removeData){
nodePtr delPtr=NULL;
温度=水头;
电流=水头;
while(当前!=NULL&¤t->data!=removeData){
温度=电流;
当前=当前->下一步;
}
如果(当前==NULL){
cout next=当前;
如果(delPtr==水头){
头部=头部->下一步;
温度=零;
}
删除delPtr;
下一步;
}
slowPtr=slowPtr->next;
}
返回slowPtr;
};
};
int main(){
利斯特Aj;
Aj.插入(5);
Aj.插入(8);
Aj.插入(10);
Aj.PrintList();
Aj.移除(8);
Aj.PrintList();
Aj.移除(5);
Aj.PrintList();
}
LList()
声明了默认构造函数,但从未实现。啊,我真不敢相信我错过了。要么我需要删除该构造函数,要么用初始值定义它。谢谢你,伊戈尔!