我想通过检查同一方法中的if条件来跳过某些代码行。我使用了goto语句,但它显示“无法从这个goto语句跳转到标签”。有没有其他方法可以让我跳过代码?我所做的是..。
if(condition)
goto skipped;
//code to skip
//code to skip
skipped:
//code to execute发布于 2018-01-24 08:21:12
goto肯定有合法的用法,所以我认为这应该有一个正确的答案:
您可能会失败的一些可能原因:
跨declarations/destructors跳转的
发布于 2016-02-06 13:32:32
if (!condition){
//code to skip if condition == YES ...
}
// continue with code which executed regardless of condition我们在面向对象编程中不使用goto。总有更好的办法。
https://stackoverflow.com/questions/35237533
复制相似问题