设计程序,测试验证static储存方式对于局部变量的生存周期影响
代码如下:
#include <iostream>
using namespace std;
void test()
{
static int num = 0;
static int a = 1;
num += 10;
cout << "这是第"<< a++ <<"次调用 test()函数,num的值为:" << num << endl;
}
void main()
{
test();
test();
test();
test();
}