+ 4

What is the use of destructor?

26th Mar 2017, 5:09 PM
Sanjay Gandhi
Sanjay Gandhi - avatar
2 Answers
+ 9
It can be used to release any resources acquired in the constructor that don't release themselves. E.g., file handles, database connections, etc.
26th Mar 2017, 5:27 PM
Igor B
Igor B - avatar
+ 2
when the object is finally destroyed the destructor is called and the code inside it is executed. Most of the time it is used to close file streams and database connection
26th Mar 2017, 5:29 PM
Dagem
Dagem - avatar