输入、编译、运行下面程序,观察变量x、y的值;并把程序的运行结果写到空格处。 实验要求:利用调试观察程序运行中变量的作用域、生存期和可见性。 include
using namespace std; void fn1(); int x = 1, y = 2; int main() { cout << "Begin..." << endl; cout << "x = " << x << endl; cout << "y = " << y << endl; cout << "Evaluate x and y in main()..." << endl; int x = 10, y = 20; cout << "x = " << x << endl; cout << "y = " << y << endl; cout << "Step into fn1()..." << endl; fn1(); cout << "Back in main" << endl; cout << "x = " << x << endl; cout << "y = " << y << endl; return 0; } void fn1() { int x=-1,y=-2; cout<<”x=”<
<