I found this code on a web site
#include <iostream>
using namespace std;
struct Base
{
Base() { cout << "Base" << " "; }
virtual ~Base() { cout << "~Base" << endl; }
int i;
};
struct Der : public Base
{
Der() { cout << "Der" << endl; }
virtual ~Der() { cout << "~Der" << " "; }
int it[10]; // sizeof(Base) != sizeof(Der)
};
int main()
{
Base *bp = new Der;
Base *bq = new Der[5];
delete bp;
delete [] bq; // this causes runtime error
}
why does it crash?