李战:
holly及各位C++高手,测试一下这个C++程序。
[阅读: 446] 2007-03-05 03:07:29
#include <stdio.h>
#include <std.h>
class TOtherObject
{
public:
TOtherObject()
{
printf("TOtherObject()\n");
};
~TOtherObject()
{
printf("~TOtherObject()\n");
};
};
class TMyObject
{
private:
auto_ptr<TOtherObject> OtherObject;
public:
TMyObject()
{
printf("TMyObject()\n");
OtherObject = new TOtherObject();
throw "TMyObject() Exception";
};
~TMyObject()
{
printf("~TMyObject()\n");
};
};
void main(void)
{
TMyObject * MyObject;
try
{
MyObject = new TMyObject();
delete MyObject;
}
catch(...)
{
printf("Catch Exception\n");
};
};
李战(leadzen)