深拷贝和浅拷贝

1. 浅拷贝(Shallow Copy):即bit-wise copy,仅通过赋值操作来拷贝类中的每个成员变量;

2. 深拷贝(Deep Copy):即member-wise copy,会将所指向的对象或变量复制到目的地,因此目的地会拥有自己的本地拷贝。

 

Shallow Copy: Shallow copy is bit-wise copy. A shallow copy copies each member of the class individually using the assignment operator.

Deep Copy: Deep copy is member-wise copy. A deep copy duplicates the object or variable being pointed to so that the destination receives local copy of its own.

 

你可能感兴趣的:(深拷贝和浅拷贝)