0
Why is destructor used in c++
3 Answers
+ 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
+ 1
ya thanks @limiltless for the explaination