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