question about class member inheritance

Say I have something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Base
{
    public:
    Base()
    { numObj++; }
    ~Base()
    { numObj--; }
    static int numObj;
};

int Base::numObj=0;

class Derived: public Base
{
    public:
    Derived()
    { numObj++; }
    ~Derived()
    { numObj--; }
    static int 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?
closed account (S6k9GNh0)
I don't see why it wouldn't be a bad idea right off hand, other than a matter of usefulness. As for your 3rd question, why don't you try it out?
Topic archived. No new replies allowed.