top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the purpose of using a destructor in c++?

+1 vote
582 views
What is the purpose of using a destructor in c++?
posted Aug 11, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

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..)

answer Aug 11, 2017 by Manikandan J
...