Consider this example :
#include <iostream>
using namespace std;
class MyClass
{
public:
~MyClass() { cout << "DTOR OK !" << endl; }
};
int main(void)
{
MyClass test();
MyClass* pTest = new MyClass();
delete pTest;
}
Why "DTOR OK !" is not printed twice ? why the destructor of the local object "test" is not called ?
When the destructor is private, I've noticed that there is only a compile error for delete pTest; but not for the local object ? what's happening here ?