我正在编写一段代码,其中一些过程在 if block 中完成。但是如果过程的结果不是预期的,我想执行 else block 。
if(condition1)
{
// Some processing
if(another condition)
//Do some task;
else
//Execute else of outer block;
}
else
{
}
最佳答案
您可以通过重写您的 if
条件来做到这一点:
if (condition1) {
// Some processing
}
if (condition1 && another condition) {
// Do some task;
} else {
// Execute else of outer block;
}
关于c++ - 如何在不使用 goto 的情况下从 if block 跳转到 else block ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56442940/