預設
在 switch 語句中,如果條件的值不等於任何 case 標籤的值,則引入將跳轉到的標籤。
char c = getchar();
bool confirmed;
switch (c) {
case 'y':
confirmed = true;
break;
case 'n':
confirmed = false;
break;
default:
std::cout << "invalid response!\n";
abort();
}
Version >= C++ 11
定義預設建構函式,複製建構函式,移動建構函式,解構函式,複製賦值運算子或移動賦值運算子以使其具有預設行為。
class Base {
// ...
// we want to be able to delete derived classes through Base*,
// but have the usual behaviour for Base's destructor.
virtual ~Base() = default;
};