我的代码不小心以以下结构结束。我不确定这样可以吗。
switch (msg.type)
{
case Msg::Type::One:
case Msg::Type::Two:
// do nothing
break;
case Msg::Type::Open:
if (msg.isBad())
break;
else // opened else branch is ok here??
// intended fall through
case Msg::Type::Close:
goodMsg.push_back(msg);
doSomethingOther();
blaBla();
break;
}
最佳答案
它可能有效,但如果您打算失败,我会完全删除 else,并发表评论说这是故意失败。
关于c++ - 在 switch-case 中打开 else 分支可以吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22887787/