Manorama
May 28th, 2002, 04:40 AM
can u tell me . Thanks
Suppose you need to keep track of how many objects of a given class exist. What is the best way (if there is one) to do this?
Choice 1
Add a static member variable that gets incremented in each constructor and decremented in the destructor.
Choice 2
This cannot be accomplished since the creation of objects can be done dynamically via "new".
Choice 3
Add a register member variable that gets incremented in each constructor and decremented in each destructor.
Choice 4
Add an automatic local variable that gets incremented in each constructor and decremented in the destructor.
Choice 5
Add an automatic member variable that gets incremented in the default constructor and decremented in the destructor.
Bye yours
Manorama
Email: raghuhari@yahoo.com
Suppose you need to keep track of how many objects of a given class exist. What is the best way (if there is one) to do this?
Choice 1
Add a static member variable that gets incremented in each constructor and decremented in the destructor.
Choice 2
This cannot be accomplished since the creation of objects can be done dynamically via "new".
Choice 3
Add a register member variable that gets incremented in each constructor and decremented in each destructor.
Choice 4
Add an automatic local variable that gets incremented in each constructor and decremented in the destructor.
Choice 5
Add an automatic member variable that gets incremented in the default constructor and decremented in the destructor.
Bye yours
Manorama
Email: raghuhari@yahoo.com