C++: why isn't the destructor designed like delete of a pointer? -
if delete pointer first time, release memory , assign null pointer. if delete pointer (with null value) second time, nothing happens, , no error throws out.
then why isn't destructor designed delete of pointer, manuall call destructor of object, , assign object, null. destructor can called many times without error?
[update] meant assign null explicitly pointer.
the whole purpose of constructors , destructors avoid manual calling of destructor. it's designed objects automatically destroyed when no longer in use. makes harder programmer accidentally forget delete object; or use object has been deleted.
Comments
Post a Comment