<cm****@hotmail.comwrote:
I have a mother class, and a child class. Can i know how man[y]
object[s]
of child exist from the mother class?
Add a protected data member to the base class. In the constructor for the
derived class, increment the count contained in the parent. If you're a
worry wart you can make it more complicated.
Instead of a count, can i add give the pointer of the current
object of the drived class to it's parent class? So the parent class
can reference all their child class's object?
I don't know of any reason that couldn't be done. It's getting complicated
enough that I would put a member function in the base class to handle the
details of adding. The function would add the newly received pointer to a
stack or vector of such pointers.