Hi,
I'm looking for a way to implement a destructor as a member method of a
class.
/* BEGIN CODE */
function SomeClass() {
this.constructor.numInstances++;
this.destroy = function () {
this.constructor.numInstances--;
/*
Need someway here to delete the instance
*/
};
}
SomeClass.numInstances = 0;
sc = new SomeClass();
// SomeClass.numInstances = 1
sc.destroy();
// SomeClass.numInstances = 0 and sc is not referenced anymore
/* END CODE */
If there was only a delete operation involved (as in -- delete sc -- in
the above exemple) , I wouldn't need a destructor, but since there is
one operation more (decrementing the number of instances; and there
could be more), and I do not want to delegate the full destruction
process to the procedure which instantiated the object, I need to
implement a destructor as a member method.
Any help would be appreciated on this.
F.