gpt4 book ai didi

c++ - 错误 : expected unqualified-id before if

转载 作者:行者123 更新时间:2023-11-28 05:59:39 28 4
gpt4 key购买 nike

<分区>

我查看了以前的答案,但没有一个解释为什么我会收到此错误。

这是我的错误代码。它出现在“if(pathID==2...)”和之后的每个 if 语句上。

void add_path(int a,int b, int current_step,int pathID){

if(pathID == 0){
path[current_step] = new step(a,b,"Filled A",path[current_step]);
}
if(pathID == 1)
path[current_step] = new step(a,b,"Filled B",path[current_step]);
}
if(pathID == 2){
path[current_step] = new step(a,b,"Empty A",path[current_step]);
}
if(pathID == 3){
path[current_step] = new step(a,b,"Empty B",path[current_step]);
}
if(pathID == 4){
path[current_step] = new step(a,b,"Pour B to A",path[current_step]);
}
if(pathID == 5){
path[current_step] = new step(a,b,"Pour A to B",path[current_step]);
}
}

所有这些代码的目的是将数组中给定位置的链表添加到链表中。传入 pathID 并告诉它执行了什么操作,因此我们知道我们知道要将什么添加到链表中。

稍后在程序中,我使用该链表来确定采取了哪些操作。我仍然需要使它成为一个双向链表,这样它就不会反向打印,但这是另一个问题。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com