When static members are inherited, are they static for the entire hierarchy, or just that class, i.e.:
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;
}
would total be 3 in all three instances, or would it be 2 for SomeClass
and 1 for SomeDerivedClass
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…