Skip to Content
Advanced C++ Programming Cookbook
book

Advanced C++ Programming Cookbook

by Dr. Rian Quinn
January 2020
Intermediate to advanced
454 pages
11h 25m
English
Packt Publishing
Content preview from Advanced C++ Programming Cookbook

Working with circular references

In this recipe, we will learn how to work with circular references. A circular reference occurs when we're using more than one std::shared_ptr, where each std::shared_ptr owns a reference to the other. This recipe is important as this type of circular reference can occur when we're working with circularly dependent objects (although this should be avoided whenever possible). If it does occur, the shared nature of std::shared_ptr results in a memory leak. This recipe will provide you with the skills to avoid said memory leak using std::weak_ptr.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern C++ Programming Cookbook

Modern C++ Programming Cookbook

Marius Bancila

Publisher Resources

ISBN: 9781838559915Supplemental Content