Ray's playground

 
上一页 1 2 3 4 5 6 7 8 9 10 ··· 56 下一页

2011年9月30日

Item 14:Use exception specifications judiciously.(More Effective C++)

摘要: It's important to keep a balanced view of exception specifications. They provide excellent documentation on the kinds of exceptions a function is expected to throw, and for situations in which violating an exception specification is so dire as to justify immediate program termination, they offe. 阅读全文

posted @ 2011-09-30 11:41 Ray Z 阅读(252) 评论(0) 推荐(0) 编辑

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) 编辑

2011年8月4日

Constants and Fields(Chapter 7 of CLR via C#)

摘要: A constant is a symbol that has a never-changing value. When defining a constant symbol,its value must be determinable at compile time. The compiler then saves the constant’s valuein the assembly’s metadata. This means that you can define a constant only for types thatyour compiler considers primit. 阅读全文

posted @ 2011-08-04 23:39 Ray Z 阅读(239) 评论(0) 推荐(0) 编辑

Type and Member Basics(Chapter 6 of CLR via C#)

摘要: The CLR offers two IL instructions for calling a method: The call IL instruction can be used to call static, instance, and virtual methods.When the call instruction is used to call a static method, you must specify the typethat defines the method that the CLR should call. When the call instruction . 阅读全文

posted @ 2011-08-04 23:35 Ray Z 阅读(183) 评论(0) 推荐(0) 编辑

2011年7月31日

Primitive, Reference, and Value Types(Chapter 5 of CLR via C#)

摘要: You need to bear in mind some performance considerations when you’re working with reference types . First, consider these facts: The memory must be allocated from the managed heap . Each object allocated on the heap has some additional overhead members associatedwith it that must be initialized . T. 阅读全文

posted @ 2011-07-31 15:22 Ray Z 阅读(300) 评论(0) 推荐(0) 编辑

2011年7月29日

Type Fundamentals(Chapter 4 of CLR via C#)

摘要: Allobjects on the heap contain two overhead members: the type object pointer and the syncblock index. 阅读全文

posted @ 2011-07-29 23:47 Ray Z 阅读(142) 评论(0) 推荐(0) 编辑

2011年6月14日

Item 9:Use destructors to prevent resource leaks. (More Effective C++)

摘要: The solution is to replace the pointer pa with an object that acts like a pointer. That way, when the pointer-like object is (automatically) destroyed, we can have its destructor call delete. Objects that act like pointers, but do more, are called smart pointers, and, as Item 28 explains, you can m. 阅读全文

posted @ 2011-06-14 14:41 Ray Z 阅读(181) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 10 ··· 56 下一页

导航