Update smart pointer exercise.
Compare changes
@@ -18,39 +21,50 @@
@@ -18,39 +21,50 @@
* Often, one has to store pointers to objects in collections. Fix the memory leaks using unique_ptr.
* - Factory functions should return objects either directly or using smart pointers, so users are forced to
@@ -64,12 +78,15 @@ struct LargeObject {
@@ -64,12 +78,15 @@ struct LargeObject {
@@ -79,7 +96,10 @@ void problem2() {
@@ -79,7 +96,10 @@ void problem2() {
largeObjects.push_back(std::move(newObj)); // Can only have one copy, so need to "give up" newObj by moving it.
@@ -98,7 +118,7 @@ void problem2() {
@@ -98,7 +118,7 @@ void problem2() {
* CONT=true; while $CONT; do valgrind --leak-check=full --track-origins=yes ./smartPointers 2>&1 | grep -B 5 -A 5 problem3 && CONT=false; done
@@ -152,61 +172,113 @@ void problem3() {
@@ -152,61 +172,113 @@ void problem3() {
@@ -217,5 +289,6 @@ int main() {
@@ -217,5 +289,6 @@ int main() {