S
Stefan Istrate
Hello,
I have a class A and I want to know at every moment what is the number
of objects of type A. I know that a good solution for this is to add a
static variable (member of class A) and increment it in constructor
and decrement it in destructor. But what if I inherit class A in more
classes (B, C, etc)? Every constructor of a child class will call the
constructor of A, so the counting will fail. What solution do you
recommend me?
Thank you,
Stefan Istrate
I have a class A and I want to know at every moment what is the number
of objects of type A. I know that a good solution for this is to add a
static variable (member of class A) and increment it in constructor
and decrement it in destructor. But what if I inherit class A in more
classes (B, C, etc)? Every constructor of a child class will call the
constructor of A, so the counting will fail. What solution do you
recommend me?
Thank you,
Stefan Istrate