我已经在静态方法中声明了一个静态成员。像下面这样:
static void temp1(param..){
static gint x,y ;
#TODO what you needed
values get changed here for x,y;
}
我想在同一文件中的其他静态方法中访问这两个。
static void temp2 ( param .......){
accessing the x,y
}
我应该怎么做...?我不想声明公共(public)成员,也不想更改方法参数。
最佳答案
这几乎就是您想要的:
static gint x,y ;
static void temp1(param..){
/* TODO what you needed */
values get changed here for x,y;
}
static void temp2 ( param .......){
/* accessing the x,y */
}
x 和 y 是全局可访问的,但只能在文件内访问, 就像您的静态过程一样。我认为这与您想要的尽可能接近。
关于c - 访问静态成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20627111/