Difference between a shallow copy and a deep copy of data


Discuss the below:

Q: Explain the difference between a shallow copy and a deep copy of data.

a. Overload the operator + for the class newString to perform string concatenation. For example, if s1 is "Hello" and s2 is "there", the statement s3 = s1 + s2; should assign "Hello there" to s3, where s1, s2 and s3 are newString objects.

b. Overload the operator += for the class newString to perform the following string concatenation; suppose that s1 is "Hello" and s2 it "there". Then the statement s1 += s2; should assign "Hello there" to s1, where s1 and s2 are newString objects.

 

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Difference between a shallow copy and a deep copy of data
Reference No:- TGS01937829

Now Priced at $20 (50% Discount)

Recommended (97%)

Rated (4.9/5)