????????C++?е?delete??delete[]????????????????????????????£??ó???????????????????????
????C++??????????????? new ???????????????????????? delete???????? new[] ??????????????????????? delete[]??
???????? new[] ?? delete[]???????????????????(1) ??????????????????????(2) ???????????????????
??????????????

 

#include <iostream>
#include<string>
using namespace std;
class T {
public:
T() { cout << "constructor" << endl; }
~T() { cout << "destructor" << endl; }
};
int main()
{
//??????”???????????“??string???????new??delete
const int NUM = 3;
string *x=new string(10??'3');
cout<<hex<<x<<endl;
delete x;
//??????”?????????????“??class T???????new??delete
T* p1 = new T;
cout << hex << p1 << endl;
//  delete[] p1;
delete p1;
//?????”?????????????“??class T[NUM]???????new[]??delete[]
T* p2 = new T[NUM];
cout << p2 << endl;
delete[] p2;
}

????????????????????????????? delete p1 ?? delete[] p1 ??????????????????н?????£?
?????????н????????????????delete p1 ????????????У???? p1[0] ???????????????????????????????? p1[1]??p1[2] ?????е???????????????????????????????????????? delete[]????????????????ж???????????????????????????
??????????????????????????????????????????????????????? delete ?? delete[] ???????????????????????????飬????? delete[]?????? new ?????????????? delete ?????? delete[] ??????
????????????????????????new ?? delete??new[] ?? delete[] ?????á?