Flashcard Details

CPlusPlus

What is the role of a destructor in C++ memory management?

A destructor is a special function called automatically when an object goes out of scope or is deleted. It releases resources like dynamic memory or file handles, ensuring proper cleanup and preventing leaks.

1

https://www.geeksforgeeks.org/destructors-c/

2