错误解决:error: expected unqualified-id before ‘)’ token

文章讨论了一个Java编程中的问题,提到在类定义中添加private关键字后才能成功编译,但不是随意添加,必须遵循特定规则。作者疑惑为什么需要这个步骤,并求助于类似菜鸟教程和ROS教程的记忆点。

报错信息与错误程序片段:

报错信息

程序片段

错误原因

没有加个private类,修改成如图后可成功编译
修改后
而且只加了private还不行,还要加一行,加的这一行还不能是空行。。。

具体原理不知道,希望有大佬能解释一下。。

我记得菜鸟教程上讲“类”那一块时没强调后面必须要加个private。。

感谢小鱼的ros教程

main.cpp: In function ‘void printStatus(const GatewayManager&): main.cpp:38:22: error: expected unqualified-id before ‘[’ token for (const auto& [id, status] : input_status) { ^ main.cpp:38:22: error: expected ‘;’ before ‘[’ token main.cpp:38:23: error:id’ was not declared in this scope for (const auto& [id, status] : input_status) { ^ main.cpp:38:27: error: ‘status’ was not declared in this scope for (const auto& [id, status] : input_status) { ^ main.cpp: In lambda function: main.cpp:38:35: error: expected ‘{’ before:token for (const auto& [id, status] : input_status) { ^ main.cpp: In function ‘void printStatus(const GatewayManager&): main.cpp:38:35: error: expected ‘;’ before:token main.cpp:38:35: error: expected primary-expression before:token main.cpp:38:35: error: expected)before:token main.cpp:38:35: error: expected primary-expression before:token main.cpp:38:35: error: expected ‘;’ before:token main.cpp:45:22: error: expected unqualified-id before ‘[’ token for (const auto& [id, status] : output_status) { ^ main.cpp:45:22: error: expected ‘;’ before ‘[’ token main.cpp:45:23: error:id’ was not declared in this scope for (const auto& [id, status] : output_status) { ^ main.cpp:45:27: error: ‘status’ was not declared in this scope for (const auto& [id, status] : output_status) { ^ main.cpp: In lambda function: main.cpp:45:35: error: expected ‘{’ before:token for (const auto& [id, status] : output_status) { ^ main.cpp: In function ‘void printStatus(const GatewayManager&): main.cpp:45:35: error: expected ‘;’ before:token main.cpp:45:35: error: expected primary-expression before:token main.cpp:45:35: error: expected)before:token main.cpp:45:35: error: expected primary-expression before:token main.cpp:45:35: error: expected ‘;’ before:token 错误原因
10-16
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值