关于构造函数中的异常处理
来源:百度文库 编辑:神马文学网 时间:2024/10/04 06:13:10
作 者:tt_xtj ()
等 级:
信 誉 值: 100
所属论坛: C/C++ C++ 语言
问题点数: 20
回复次数: 13
发表时间: 2006-10-12 13:17:05
在c++中,如果对象的构造函数有异常被抛出,则该对象不会被构造,对吗?所
那么,构造该对象所分配的空间由谁负责释放(如果该对象是由new在堆中分配的呢)?
例如如下代码:
#include
#include
using namespace std;
class test
{
public:
test(int m):n(m)
{
cout<<"Input:\n";
cin>>s;
if (s=="exception")
{
cout<
}
}
virtual ~test()
{
}
private:
int n;
string s;
int t;
};
void main()
{
test*ptrT;
try
{
ptrT=new test(6);
}
catch (string s)
{
cout<
//delete ptrT;
test t2(8);
}
关于构造函数中的异常处理
构造函数中异常的处理? 开发宝典 DevDic.com
c++中的异常处理
浅谈c++中的拷贝构造函数
浅谈c++中的拷贝构造函数
论C++构造函数中的不合理设计_威尼斯迷路
Web服务中的异常处理(1)
数据结构中的copy构造函数和赋值重载函数-坚强的心-搜狐博客
C++拷贝构造函数
拷贝构造函数
构造函数而不是类
拷贝构造函数
拷贝构造函数1
C++拷贝构造函数
c++拷贝构造函数
构造函数属性
异常处理
异常处理
构造函数为什么不能是虚函数
关于Java日期处理函数.[不断更新] - feng_sundy的专栏 - CSDNBlo...
异常处理方法
异常处理经验谈
通用异常处理框架
通用异常处理框架