相关疑难解决方法(0)

方法中的静态局部变量是不好的做法?

有些东西让我烦恼.

在非线程程序中,最好是使用本地静态变量(内部方法)还是静态类成员?

在这个例子中:

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()吗?

c++ variables static

9
推荐指数
1
解决办法
6361
查看次数

标签 统计

c++ ×1

static ×1

variables ×1