Skip to content
Snippets Groups Projects
Commit dfb2ca0e authored by Stephan Hageboeck's avatar Stephan Hageboeck
Browse files

Update smart pointer part of cheat sheet.

parent 86a6951b
No related branches found
No related tags found
1 merge request!14Update smart pointer exercise.
......@@ -118,10 +118,10 @@ Level 3 : use the genericity of the Complex class and play with Complex of integ
### smartPointer
Here we have four code snippets that will benefit from using smart pointers.
* `problem1` is a simple case of usage of `make_unique` with an observer pattern where the raw pointer shoule be used.
* `problem2` is an example of a collection of pointers. Move semantic has to be used to transfer ownership of newly created objects to the container.
* `problem1` is a simple case of usage of `make_unique` with an observer pattern where the raw pointer should be used.
* `problem2` is an example of a collection of pointers. Move semantic has to be used to transfer ownership of newly created objects to the container (alternatively, `emplace_back`).
* `problem3` is an example of shared ownership where `std::shared_pointer` should be used.
* `problem4()` is the most difficult. Skip if not enough time. It has the same flow as the memcheck problem, that destructor should be virtual in the Base class
* `problem4` demonstrates the usage of `shared_ptr` as class members. It has a second part where a `weak_ptr` can be used, but can be skipped if not enough time.
### stl
The goal is to use STL algorithms. I would advise to start in this order :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment