Windows 程序调试心得01

最近看了Everett N.McKay & Mike Woodring 的classical Debugging Windows Programs谈谈一些收获,以共大家分享. sharing with everybody

1.试着处理可能在程序里出错的构造函数.

Try to disposal construct function which was likely to slip a cog in a programme.

---------

CMyObject::CMyObject(const CString &resourse1,const CString &resourse2)

{

  //Do safe initialization first

  m_pRourse1=0;

  m_pRourse2=0;

}

//now do initialization that can fail

try{

  m_pRourse1=CreateResourse(resourse1);

   m_pRourse2=CreateResourse(resourse2);

}

catch(...){

//  must clean up here,since destructor won`t be called.

delete m_pResourse1;

delete m_pResourse2;

m_pResourse1=0;

m_pResourse2=0;

throw;

}

 2.保证析构函数中的异常在析构函数内部得到处理.

Make sure the exception in destruct function be resolved in iteself.

---------

the same as the construct.(omit)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值