默认

在 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;
};