int Date::set(int a,int b,int c) {
// ... 計算 s ...
return s;
cout << "s=" << s << endl; // 永遠不會執行
}
int Date::set(int a,int b,int c) {
// ... 計算 s ...
cout << "s=" << s << endl; // 先輸出
return s; // 再返回
}
return 會**立即結束函數**,其後所有語句均為死碼。編譯器通常會警告 "unreachable code"。