3 ms·
If we're being pedantic here, destructors don't manage memory at all, they only free resources. Memory is freed by the caller of the destructor, either automati
by brianush1 7y ago
If we're being pedantic here, destructors don't manage memory at all, they only free resources. Memory is freed by the caller of the destructor, either automatically if the memory was allocated on the stack, or manually by the delete operator if the memory was allocated on the heap.
- Someone 7y agoMemory is a resource, too, and C++-style destructors do manage it, sometimes. Destructors do not free the memory of the object being destroyed, but they can free memory that its fields point to.