我们需要在自己的类中实现clone方法吗?

  Should you implement clone in your own classes? If your clients need to make deep copies, then you probably should. Some authors feel that you should avoid clone altogether and instead implement another method for the same purpose. We agree that clone is rather awkward, but you’ll run into the same issues if you shift the responsibility to another method. At any rate, cloning is less common than you may think. Less than 5 percent of the classes in the standard library implement clone.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,499评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 10,131评论 0 23
  • 1、梁晓声在《忐忑的中国人》一书中描述过他的恩师黄宗英: 她有一颗永远年轻的心,那样一颗心即使某一天停止了跳动,前...
    P静鸿阅读 179评论 0 0
  • 离Stellaris发售还剩两天,可惜我还没考完。 今天《三体》三部曲亚马逊下单了,中文版的。暑假前一个月边玩游戏...
    上海王尔德阅读 205评论 1 2