I have the following code. It calls the class's destructor indefinitely and crashes. If I change the size of the array to something larger than 0 is works fine.
#include <iostream>
using namespace std;
class ClassA {
public:
ClassA() {
cout << "constructor" << endl;
}
~ClassA() {
cout << "destructor" << endl;
}
};
int main() {
ClassA *ptr;
cout << (void*) ptr << endl;
ptr = new ClassA[0];
cout << (void*) ptr << endl;
delete[] ptr;
cin.get();
return 0;
}