class CDemo {
public:
CDemo(const char *str);
~CDemo();
private:
char name[20];
};
CDemo::CDemo(const char* str) {
strcpy(name,str);
cout < <"cout:Construction called for " < <name < <endl;
}
CDemo::~CDemo() {
cout < <"cout:Destruction called for " < <name < <endl;
printf(" printf:Destruction called for %s\n",name);
}
static CDemo GlobleObject("globeobject");
void main() {
CDemo LocalObjectInMain("localobjectinmain");
CDemo * pHeapObjectInMain=new CDemo("heapobjectinmain");
CDemo *pHeapObjectInFunc=new CDemo("heapobjectinfunc");
static CDemo StaticObject="staticobject";
}
这里globeobject的析构并没有被显示出来,为什么呢?