【求助】为什么析构两次不报错??
//cat类#include <iostream>
using namespace std;
class cat
{private:
static int howmanycat;
public:
cat(){cout<<"构造\n";howmanycat++;}
static void gethowmanycat(){cout<<howmanycat<<endl;}
~cat(){cout<<"析构\n";--howmanycat;}
};
int cat::howmanycat=0;
void main()
{
int n;
cout<<"n=";
cin>>n;
cat *p;
p=new cat[n];
for(int i=0;i<n;i++)
{
(p+i)->gethowmanycat();
(p+i)->~cat();
}
delete [] p;
}