Ray's playground

 

2011年3月28日

Item 25: Consider support for a non-throwing swap(Effective C++)

摘要: Provide a swap member function when std::swap would be inefficient for your type. Make sure your swap doesn't throw exceptions. If you offer a member swap, also offer a non-member swap that calls the member. For classes (not templates), specialize std::swap, too. When calling swap, employ a usin 阅读全文

posted @ 2011-03-28 20:41 Ray Z 阅读(204) 评论(0) 推荐(0) 编辑

Item 24: Declare non-member functions when type conversions should apply to all parameters(Effective C++)

摘要: If you need type conversions on all parameters to a function (including the one pointed to by the this pointer), the function must be a non-member. 阅读全文

posted @ 2011-03-28 17:54 Ray Z 阅读(149) 评论(0) 推荐(0) 编辑

Project Euler Problem 23

摘要: A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.A numbernis called deficient if the sum of its proper divisors is less tha 阅读全文

posted @ 2011-03-28 15:26 Ray Z 阅读(254) 评论(0) 推荐(0) 编辑

Item 23: Prefer non-member non-friend functions to member functions(Effective C++)

摘要: Prefer non-member non-friend functions to member functions. Doing so increases encapsulation, packaging flexibility, and functional extensibility. 阅读全文

posted @ 2011-03-28 12:02 Ray Z 阅读(155) 评论(0) 推荐(0) 编辑

Manipulating Strings(Chapter 6 of Objective-C Phrasebook)

摘要: Foundation provides a class for assigningarbitrary attributes to strings. TheNSAttributedString class lets you attachdictionaries to ranges in attributed strings.These dictionaries can contain any arbitraryinformation that you want, including semanticmarkup. It’s important to remember that sending . 阅读全文

posted @ 2011-03-28 11:48 Ray Z 阅读(173) 评论(1) 推荐(0) 编辑

导航