Shallow Copy vs Deep Copy (Part III)

Опубликовано: 10 Июнь 2026
на канале: Brian MalloyOn
2,771
17

In this video we show that the notion of shallow copy and deep copy is important when writing programs in all languages, such as Python. We use Python lists to show that if you don't make a deep copy you actually get a shallow copy, with all of the problems inherent to shallow copy. We then extend the notion to a Python list of lists. We then relate back to C++, write a setBuf member function for the string class, and show how, in the presence of shallow copy, the same problem that occurred in Python also occurs in C++.