为什么 三次打印 h 分别为 48 2 2
#include<iostream>
using namespace std;
int total = 1;//静态存储区
int f(int x)//动态存储区
{
int a =1, b =2;
return x + a + b;
}
int g();
int main()
{
int a = 3;//动态存储区
{
int b = 4;//动态存储区
}
g();f(a);g();
f(a);g();
return 0;
}
int g()
{
static int times = 0;
int y = 2;
cout <<"times= " <<++times<<endl;
static int temp;
int h;
cout <<"temp="<<temp<<endl;
cout <<"h="<<h<<endl;
return 0;
}