有些东西让我烦恼.
在非线程程序中,最好是使用本地静态变量(内部方法)还是静态类成员?
在这个例子中:
class C{
public:
C(){};
void foo();
};
void C::foo(){
static int bar = 0;
bar++;
printf("%d\n",bar);
}
Run Code Online (Sandbox Code Playgroud)
如果bar
单独使用它会被认为是一种不好的做法C::foo()
吗?