3 in all cases, since the static int total inherited by SomeDerivedClass exactly matches SomeClass , not a separate variable.
Edit: actually 4 in all cases, as @ejames noticed and indicated in his answer that they see.
Edit: the code in the second question is absent in int in both cases, but adding it makes it OK, that is:
class A { public: static int MaxHP; }; int A::MaxHP = 23; class Cat: A { public: static const int MaxHP = 100; };
It works fine and with different values ββfor A :: MaxHP and Cat :: MaxHP - in this case, the subclass does not "inherit" the static from the base class, because, so to speak, it "hides" it using its own eponymous.
Alex Martelli Jun 15 '09 at 20:41 2009-06-15 20:41
source share