析构函数的实现问题,求指教
#include<iostream>using namespace std;
int count=0;
class alpha
{
public:
alpha()
{
count++;
cout<<"\nNO.of object destroyde"<<count;
}
~alpha()
{
cout<<"\nNO.of object destroyed"<<count;
count--;
}
};
int main()
{
cout<<"\n\nENTER MAIN\n";
alpha A1,A2,A3,A4;
{
cout<<"\n\nENTER BLOCK1\n";
alpha A5;
}
{
cout<<"\n\nENTER BLOCK2\n";
alpha A6;
}
cout<<"\n\nRE-ENTER MAIN\n";
return 0;
}
对象A1,A2,A3,A4生成后为什么不是当场销毁,而是等到A5,A6销毁后才销毁的。。。