+ 1

How destructors help to release memory?

.......

4th Sep 2019, 8:19 AM
Pardeep
Pardeep - avatar
2 Respostas
+ 3
The memory used to store old objects can be freed up to create new objects. As memory is a finite resource, releasing memory is important in software that can consume a lot of it.
4th Sep 2019, 8:47 AM
Sonic
Sonic - avatar
0
If you dynamically allocate memory in a class(with new), you should free that memory (with delete) to prevent memory leaks. Usually, the class destructor is a good place to do that.
4th Sep 2019, 9:22 AM
daniel
daniel - avatar