实例 C++ 使用 default 关键字的 switch 语句

x
 
#include <iostream>
using namespace std;
int main() {
  int day = 4;
  switch (day) {
    case 6:
      cout << "Today is Saturday";
      break;
    case 7:
      cout << "Today is Sunday";
      break;
    default:
      cout << "Looking forward to the Weekend";
  }
  return 0;
}
                    

输出结果

Looking forward to the Weekend