Calling destructor to free dynamically allocated memory

  c++, destructor, dynamic-memory-allocation

Calling destructor to free dynamically allocated memory

Let consider this code:

#include <iostream>
class A{
public:
        ~A() {}
};
int main(){
        A *p = new A();
        p->~A();
        return 0;
}

I would like to know if the memory of the object A pointed by p is freed or we must to call delete p;


Source: StackOverflow C++

LEAVE A COMMENT