【基础知识】深拷贝和浅拷贝的区别是什么?

【原文链接】https://stackoverflow.com/questions/184710/what-is-the-difference-between-a-deep-copy-and-a-shallow-copy

Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements.

Deep copies duplicate everything. A deep copy of a collection is two collections with all of the elements in the original collection duplicated.

猜你喜欢

转载自blog.csdn.net/sinat_40431164/article/details/81181931
今日推荐