Ray's playground

 

Item 27: Minimize casting.(Effective C++)

  • Avoid casts whenever practical, especially dynamic_casts in performance-sensitive code. If a design requires casting, try to develop a cast-free alternative.

  • When casting is necessary, try to hide it inside a function. Clients can then call the function instead of putting casts in their own code.

  • Prefer C++-style casts to old-style casts. They are easier to see, and they are more specific about what they do.

posted on 2011-03-30 11:36  Ray Z  阅读(184)  评论(0编辑  收藏  举报

导航