关于下面程序,说法正确的是( )。
void show() {
int stars = 5;
}
int main() {
cout << stars;
return 0;
}
- A. 程序输出 5
- B. 程序可以通过编译,但输出随机值
- C. 程序不能通过编译,因为 stars 只在 show 函数中有效
- D. 程序不能通过编译,因为 cout 不能输出变量
正确答案:C
void show() {
int stars = 5;
}
int main() {
cout << stars;
return 0;
}
正确答案:C
想系统刷完 GESP C++ 1~8 级真题,并查看每道题的逐题精讲?
进入 GESPPASS 开始练习