cmu-db / 15445-bootcamp

A basic introduction to coding in modern C++.
Apache License 2.0
724 stars 148 forks source link

docs: copy-constructor vs copy-assignment #5

Open El-even-11 opened 1 year ago

El-even-11 commented 1 year ago

https://github.com/cmu-db/15445-bootcamp/blob/e2d462b821e29440da1f038e61589866c32d9dad/src/shared_ptr.cpp#L79-L80

Might use copy-constructor here?

El-even-11 commented 1 year ago
// copy-constructed
std::shared_ptr<Point> s4 = s3;

// copy-assigned
std::shared_ptr<Point> s4;
s4 = s3;
cscourage commented 1 year ago

I totally agree with you too. "std::shared_ptr<Point> s4 = s3; " should be copy-construction, because it is the first time s4 appears.

"std::shared_ptr<Point> s4; // default construction s4 = s3;" // copy-assignment. and this is the situation where copy-assignment works.

skyzh commented 1 year ago

yep, this looks like a typo. would you please submit a pull request? thanks!