Exercises in this lecture  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Go to the slide, where this exercise belongs -- Keyboard shortcut: 'u'  

Exercise 4.4
A variant of the unique_ptr program


The program above passes a raw pointer to a Point to the function f. It is probably a better idea to wrap p (the point (1,2)) in a unique_ptr already in main, and to pass a unique_ptr to f. Provide for this change.

In addition we want to return (the ownership of) the unique_ptr in a2 back to main via a value return. Please do that.

In this exercise, please be aware that unique pointers cannot be copied - they must be moved.


The solution to this exercise has not yet been released