class Base
{
public:
Base()
{ numObj++; }
~Base()
{ numObj--; }
staticint numObj;
};
int Base::numObj=0;
class Derived: public Base
{
public:
Derived()
{ numObj++; }
~Derived()
{ numObj--; }
staticint numObj;
};
int Derived::numObj=0;
Is this a bad idea? Should I just name the derived counter separately? I'm guessing that numObj would end up shadowing each other or something like that - would writing Derived::numObj++ work within the constructor?