As stated in the title, here is my code:
class Foo {
public:
Foo (int charSize) {
str = new char[charSize];
}
~Foo (
Calling a destructor releases the resources owned by the object, but it does not release the memory allocated to the object itself. The second code snippet has a memory leak.
Whenever a call to destructor is made , the allocated memory to the object is not released but the object is no longer accessible in the program. But delete completely removes the object from memory.