BOOL foo(void){
static BOOL displayed = FALSE;
static BOOL initialized = FALSE;
if (displayed)
return FALSE;
//more code
displayed = TRUE;
return FALSE;
}
C中静态局部变量的含义是什么?C中静态局部变量的含义是什么?
如果第二次调用此方法,displayed
将不会重新初始化为FALSE?
https://stackoverflow.com/questions/14992116/cc-the-purpose-of-static-const-local-variable – Brian
可能重复[什么是静态局部变量的用法,当我们可以得到一个全局变量在同样的成本?](http://stackoverflow.com/questions/15808049/what-is-the-use-of-static-local-variable-when-we-can-get-a-global-variable-at -th) – Brian
如果第二次调用此方法,显示将不会重新初始化为FALSE? - 不,它会保留上次分配给它的值 –