我有兩個問題 - (I)使用 「否則,如果」 在C++中
code-fragment-1
if(<condition-statement>){
}
else if(<condition-statement-2>){
//statements-1
}
//statements-2
代碼片段的2
if(<condition-statement>){
}
else{
if(<condition-statement-2>){
//statements-1
}
//statements-2
}
是上述兩個代碼片段一樣嗎? (II)何時使用ifs(在C++中)?
一個開關語句總是優先於多個「其他如果」分支,或者我得到錯誤的想法 – clockw0rk