Open BruceWayneLinxu opened 6 years ago
I would agree, especially since we have move semantics now. That function could just be refactored into array& operator=(array&& b). Not sure how this works in the context of the book though; it might be worth staying consistent with what Java is doing, since that's the original language used in the book.
// https://github.com/patmorin/ods/blob/master/cpp/array.h array& operator=(array &b) {
if (a != NULL) delete[] a;
a = b.a;
b.a = NULL;
length = b.length;
return *this;
}
a = b.a; // This is not deep copy.