我有这样的代码
class TestA
{
public:
TestA() { a = new int(1); }
~TestA() { delete a; cout << "~A" << endl; }
int* a;
};
int main() {
TestA* a = new TestA[10];
delete a;
TestA* aa = new TestA();
delete[] aa;
}
在visual studio2019中执行,两个delete都会出错,想请教一下出错的原因,希望是从原理的角度解释。感谢感谢