在c ++中控制流语法

Dan*_*ani 2 c++ syntax control-flow

使用以下c ++示例(intention故意遗漏).

if(condA)          // if #1
if(condB)          // if #2
if(condC)          // if #3
if(condD)          // if #4
funcA();
else if(condD)     // else #1 if #5
funcB();
else if(condE)     // else #2 if #6
funcC();
else               // else #3
funcD();
else if(condF)     // else #4 if #7
funcE();
else               // else #5
funcF();
Run Code Online (Sandbox Code Playgroud)

什么else是if关于这个的规则是什么?(是的,我知道使用{ }会解决这个问题).

Pup*_*ppy 5

if(condA)          // if #1
    if(condB)          // if #2
        if(condC)          // if #3
            if(condD)          // if #4
                funcA();
            else if(condD)     // else #1 if #5
                funcB();
            else if(condE)     // else #2 if #6
                funcC();
            else               // else #3
                funcD();
        else if(condF)     // else #4 if #7
            funcE();
        else               // else #5
            funcF();
Run Code Online (Sandbox Code Playgroud)