c++中静态变量不但要在头文件中declare,还要在实现的cpp中declare。当然也可以赋个初始值。
class foo
{
int _i;
public:
foo(int i) : _i(i) {}
};
class bar
{
public:
static int j;
static foo f;
};
int bar::j = 0;
foo bar::f(1);
c++中静态变量不但要在头文件中declare,还要在实现的cpp中declare。当然也可以赋个初始值。
class foo
{
int _i;
public:
foo(int i) : _i(i) {}
};
class bar
{
public:
static int j;
static foo f;
};
int bar::j = 0;
foo bar::f(1);