i get some collection of solutions please help me to find correct one.
-> add member variable increment in default constructor and decrement in destructor.
-> add local variable that goes incremented in each constructor and decremented in destructor.
-> add static member variable that get incremented in each constructor and decremented in the destructor.
-> cannot be accomplished since the creation of the objects is being done dynamically via “new”.
these are my four points please select me the best.
Use a static member variable:
But remember that you can create new instances without hitting the constructor (namely via
clone,__set_state()(which is used byvar_export) andunserialize)… So you’ll need to add: