中国开发网: 论坛: 程序员情感CBD: 贴子 479504
李战
holly及各位C++高手,测试一下这个C++程序。
#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)

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录