0

Why is destructor used in c++

1st Sep 2017, 12:10 PM
Ravi Gautam
Ravi Gautam - avatar
3 Respostas
1st Sep 2017, 1:06 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
Every variable, every class is using memory and energy to make the program work. If you make a program that does a lot of calculatulions and uses a lot of variables, you need to clarify what they are. But just as we "create" them we need to "destroy" them. We do this to free the memory the class used. In C++ and C it's needed to do this. But in programming languages like Java and C# it's not needed, because of the Garbage collection system that has been built-in. I hope this helped you explain why we use deconstructors
1st Sep 2017, 12:22 PM
Limitless
Limitless - avatar
+ 1
ya thanks @limiltless for the explaination
1st Sep 2017, 3:19 PM
Ravi Gautam
Ravi Gautam - avatar