Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 960 Bytes

smart_pointers_summary.md

File metadata and controls

18 lines (13 loc) · 960 Bytes

Smart pointers - summary

  • #include <memory>
  • std::unique_ptr<> for exclusive ownership
  • std::shared_ptr<> for shared ownership
  • std::weak_ptr<> for observation and breaking cycles

Exercise: ResourceFactory

  1. Compile and run ResourceFactory application
  2. Put comments in places where you can spot some problems
  3. How to remove elements from the collection (vector<Resource*> resources)?
  4. Check memory leaks
  5. Fix problems