Ray's playground

 

2011年9月29日

Item 11:Prevent exceptions from leaving destructors.(More Effective C++)

摘要: We thus find ourselves with two good reasons for keeping exceptions from propagating out of destructors. First, it prevents terminate from being called during the stack-unwinding part of exception propagation. Second, it helps ensure that destructors always accomplish everything they are suppose... 阅读全文

posted @ 2011-09-29 22:17 Ray Z 阅读(244) 评论(0) 推荐(0) 编辑

Item 13:Catch exceptions by reference.(More Effective C++)

摘要: There are thus three primary ways in which passing an object to a function or using that object to invoke a virtual function differs from throwing the object as an exception. First, exception objects are always copied; when caught by value, they are copied twice. Objects passed to function para... 阅读全文

posted @ 2011-09-29 15:44 Ray Z 阅读(232) 评论(0) 推荐(0) 编辑

Item 12:Understand how throwing an exception differs from passing a parameter or calling a virtual function.

摘要: There are thus three primary ways in which passing an object to a function or using that object to invoke a virtual function differs from throwing the object as an exception. First, exception objects are always copied; when caught by value, they are copied twice. Objects passed to function para... 阅读全文

posted @ 2011-09-29 15:29 Ray Z 阅读(217) 评论(1) 推荐(0) 编辑

Item 10:Prevent resource leaks in constructors.(More Effective C++)

摘要: It all adds up to this: if you replace pointer class members with their corresponding auto_ptr objects, you fortify your constructors against resource leaks in the presence of exceptions, you eliminate the need to manually deallocate resources in destructors, and you allow const member pointers... 阅读全文

posted @ 2011-09-29 15:19 Ray Z 阅读(189) 评论(0) 推荐(0) 编辑

导航