Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Cleared up some language on the answer to question 13.24.
  • Loading branch information
Pethaf committed Mar 18, 2016
1 parent 6d38d55 commit d67aec3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ch13/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Check 13.22.
## Exercise 13.24:
>What would happen if the version of `HasPtr` in this section didn’t define a destructor? What if `HasPtr` didn’t define the copy constructor?
If `HasPtr` didn't define a destructor, memory leak will happened. If `HasPtr` didn't define the copy constructor, when assignment happened, just points copied, the string which `ps` points haven't been copied.
If `HasPtr` didn't define a destructor, a memory leak would occur, compiler synthesized destructor does not manage dynamic memory. If `HasPtr` didn't define the copy constructor, we would get pointer-like copy behaviour. The ps pointer would be copied to the left hand side, but ps in the lhs and the rhs would still point to the same string on the heap.

## Exercise 13.25:
>Assume we want to define a version of `StrBlob` that acts like a value. Also assume that we want to continue to use a shared_ptr so that our `StrBlobPtr` class can still use a weak_ptr to the vector. Your revised class will need a copy constructor and copy-assignment operator but will not need a destructor. Explain what the copy constructor and copy-assignment operators must do. Explain why the class does not need a destructor.
Expand Down

0 comments on commit d67aec3

Please sign in to comment.