Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I think it is better to make it deep copy. #65

Open
BruceWayneLinxu opened this issue Dec 1, 2017 · 1 comment
Open

I think it is better to make it deep copy. #65

BruceWayneLinxu opened this issue Dec 1, 2017 · 1 comment

Comments

@BruceWayneLinxu
Copy link

// 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.

@tekinozbek
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants