什么是好的,什么是错的?在这种情况下,我必须调用 delete 以防止内存泄漏?此外,C 和 C++ 中的行为是否完全相同?有什么不同吗?
const char* a = "blahblah";
...
delete a;
char b* = new char('a');
...
delete b;
char c[100] = "blahblah";
...
delete c;
char d* = new char[40];
...
delete d;
char e* = new char[40];
...
delete[] e;