错误:在if之前需要不合格的id
error: expected unqualified-id before if
我已经查看了以前的答案,但没有一个解释我为什么会出现这个错误。
这是我的错误代码。它发生在"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]);
}
}
所有这些代码所要做的就是将其添加到数组中给定位置的链表中。路径ID被传入,告诉它执行了什么操作,所以我们知道我们知道要向链表添加什么。
在程序的后期,我使用该链接列表来确定采取了哪些操作。我仍然需要使它成为一个双链接列表,这样它就不会反向打印,但这是另一个问题。
后忘记了大括号
if(pathID == 1)
加上它就会很好用。
相关文章:
- 方法内部但循环仍得到预期的不合格id错误C++
- C 预期的不合格ID(类继承)
- 解析问题:预期的不合格的ID和语义问题:C 需要所有声明的类型说明符
- 字符串常量(包括ZenLib/Ztring.h)之前应为不合格id
- Arduino-应为不合格的id
- int之前应为不合格id
- while c++之前应为不合格id
- 预期的不合格id错误,很可能是原因
- 标头C++中应为不合格Id
- 不合格的ID和模板类
- C++中类出现预期的不合格id错误
- QDir目录之前应为不合格的id
- 第25行应为不合格的-id,我该如何更正
- 错误:“int”之前应为不合格的id
- iOS中出现不合格的id错误
- 奇怪的模板错误:应为不合格id
- C++:错误:在“!”之前应为不合格的id代币
- 错误:在if之前需要不合格的id
- 不合格的id错误和井字游戏板不工作
- 在int j之前预期的不合格id.我知道它可能偏离主题,但我找不到错误