// 函数的默认参数 #include using namespace std; bool isSs(int n = 10) // 判断 n 是否为质数 { int i = 2; for (; i < n / 2; i++) { if (n % i == 0) return false; // 0 为假 } return true; // 非 0 为真 } double area(double r = 1.0) // 求面积 { return 3.14 * r * r; } int main() { cout << "isSS(7) is " << isSs(7) << endl; cout << "isSS() is " << isSs() << endl; cout << "area() is " << area() << endl; cout << "area(2) is " << area(2) << endl; return 0; }