1.局部变量

static局部变量和普通局部变量有什么区别:static局部变量只被初始化一次,下一次依据上一次结果值;

int test(int j){
static int i=10;
i=i+j;
return i;
}

int main(void)
{
	////美图秀秀笔试
	
	int m=test(12);
	int n=test(4);
	cout << m <<endl; //输出 22
	cout << n <<endl; //输出 26
}

  

posted on 2014-05-19 23:07  zhangxh_Doris  阅读(172)  评论(0)    收藏  举报