是否可以在 Go 中定义一个局部变量,该变量可以从一个函数调用到另一个函数保持其值?在 C 中,我们可以使用保留字来做到这一点static。
C 中的示例:
int func() {
static int x = 0;
x++;
return x;
}
泛舟湖上清波郎朗
动漫人物
相关分类