Does the Destructor just deallocates the memory or actually deletes the object
A destructor calls the destructors of subobjects (if any), executes the destructor body (if it is defined). It is technically not the destructor that deallocates the memory. The destrcutor can be called without deallocation, and memory can be deallocated without the call to a destructor.
When a dynamic object is deleted with operator delete
, the destructor will be called, and then the memory is deallocated. Likewise, when the life time of an automatic variable (such as your n
) ends, its destructor is called, and the memory is deallocated.
It is unclear what you mean by "deletes the object". A destructor will never call the delete
operator (unless the body of the destructor {,of a sub object} sub object calls delete
operator, but then it is not this
that is deleted).
If you mean whether destructor destroys the object, then it is the other way 'round: When an object is being destroyed, its destructor will be called.
- ... But the pointer points to the same object
The pointer points to where the object was. That object has been destroyed and no longer exists.
... and its member functions are still accessible.
Accessibility of a member function does not depend on what is being pointed. Dereferencing a pointer (including calling a member function) that does not point to an object has undefined behaviour.
Doesn't this mean that the object isn't deleted yet?
No. You can't make conclusions from undefined behaviour.
- Does overriding the destructor function ...
This is not overriding. Overriding is a specific language term that involves inheritance and virtual functions.
What you have done is define a destructor.
- ... and doing nothing in it (here in ~name()), prevent the object from being deleted?
No. Doing nothing in the body of the destructor is exactly the same what the implicit destructor does (the one that the object had when you left the destructor undefined). It does not "prevent the object form being deleted".