To take care of garbage collection in c++
The main purpose of destructor is to free all the resources which you have allocated during your object's life time. Example: Freeing resources like memory allocations, opened files, opened sockets, database connections, resource locks etc..)