Ray's playground

 

Item 11: Handle assignment to self in operator=(Effective C++)

Make sure operator= is well-behaved when an object is assigned to itself. Techniques include comparing addresses of source and target objects, careful statement ordering, and copy-and-swap.
Make sure that any function operating on more than one object behaves correctly if two or more of the objects are the same.

posted on 2009-12-27 13:31  Ray Z  阅读(163)  评论(0编辑  收藏  举报

导航