Hence the code below.
class A
{
int x;
public:
A() {x = 3;}
};
int main()
{
void* mem = operator new(sizeof(A));
A* obj = static_cast<A*>(new(mem)(A));
std::cout << obj->x << std::endl;
obj->A::~A();
std::cout << obj->x << std::endl;
}
My first question is: Why I can directly call the destructor of A; My second question is: Why the output is:
3
3
The the object obj is not deleted after the destructor call? The second 3 bothers me.