当继承静态成员时,它们是整个层次结构的静态成员,还是仅仅是该类的静态成员,例如:
class SomeClass
{
public:
SomeClass(){total++;}
static int total;
};
class SomeDerivedClass: public SomeClass
{
public:
SomeDerivedClass(){total++;}
};
int main()
{
SomeClass A;
SomeClass B;
SomeDerivedClass C;
return 0;
}
在所有三个实例中总共是3个,或者 SomeClass
是2个,SomeDerivedClass
是1个?