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

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -